using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Soap;
using System.Windows.Forms;
using ODT.Common.Core;
using ODT.Common.Services;
using ODT.PMACGlobal;
using PPChartControl.Properties;
using ZedGraph;

namespace PPChartControl
{
	public class PPChartControl : UserControl
	{
		public enum ChartType
		{
			Plot,
			Tune,
			None
		}

		public enum CanSave
		{
			YES,
			NO
		}

		public delegate void ChartFileIO(object sender, string pppFileName);

		private sealed class Version1ToVersion2DeserializationBinder : SerializationBinder
		{
			public override Type BindToType(string assemblyName, string typeName)
			{
				Type zedGraphType = GetZedGraphType(assemblyName, typeName);
				if (zedGraphType != null)
				{
					return zedGraphType;
				}
				string fullName = Assembly.GetExecutingAssembly().FullName;
				string text = "Version1Type";
				if (assemblyName == fullName && typeName == text)
				{
					typeName = "Version2Type";
				}
				return Type.GetType($"{typeName}, {assemblyName}");
			}

			private static Type GetZedGraphType(string assemblyFullName, string typeName)
			{
				string obj = assemblyFullName.Split(',')[0];
				AssemblyName name = typeof(ZedGraphControl).Assembly.GetName();
				if (!(obj == name.Name))
				{
					return null;
				}
				return Type.GetType($"{typeName}, {name.FullName}");
			}
		}

		private CultureInfo enUSCulture = new CultureInfo("en-US");

		private PointPairList nlist = new PointPairList();

		private RollingPointPairList xy = new RollingPointPairList(1000);

		public static IChartControl _plotdetails = new IChartControl();

		private FormProperty cProperty = new FormProperty(false);

		public string INIFileName = string.Empty;

		private string defaultPath;

		private string DefaultPath
        {
            get
            {
				return defaultPath;

			}
			set
            {
				defaultPath = value;
				if (!Directory.Exists(defaultPath))
                {
					defaultPath = System.AppDomain.CurrentDomain.BaseDirectory + "\\DefaultStore";
					Directory.CreateDirectory(defaultPath);
				}
			}
        }

		public double SampleTime;

		public bool istuneplot;

		public bool iscurrentstepplot;

		private bool isgantry;

		private bool issinesweep;

		private bool isopenloop;

		private string stats;

		private double[] commandedpos;

		private double[] actualpos;

		private double[] servocommand;

		private double[] timeinms;

		private double[] idmeasured;

		private double[] timeinphasecycles;

		private double homeposition;

		private double cmdposinitial;

		private double tscurrent;

		private int xcol;

		private int xrow;

		private string horizantalaxisitem;

		private int[] leftaxisitem = new int[6];

		private int[] rightaxisitem = new int[6];

		private string sleftaxisitem;

		private string srightaxisitem;

		private string title;

		private double[] actualpos_gantry;

		private double[] servocommand_gantry;

		private double homeposition_gantry;

		private double masterposition_gantry;

		private int normalizedplot;

		private double gathertime;

		private double start_freq;

		private double end_freq;

		private double sweep_time;

		private double sweep_magnitude;

		private bool islogaritmic;

		private bool isfreqbasedplot;

		private bool movingaveragefiltered;

		private int mafilterorder;

		private string timeMillisecondsText;

		private string timeSecondsText;

		private string positionText;

		private string productNameText;

		private string plotText;

		private string graphToolTipTextFormat;

		private string pageSetupText;

		private string printPreviewText;

		private string printText;

		private string propertiesText;

		private string setScaleToDefaultText;

		private string bufferSizeAxisTextFormatText;

		private string queueSizeAxisTextFormatText;

		private string fftInformationText;

		private string wouldYouLikeToFilterTheSignalsText;

		private string wouldYouLikeTheSignalsInDecibelsText;

		private string frequencyText;

		private string invalidFileFormatTextFormat;

		private string allFilesText;

		private string plotErrorText;

		private string fftErrorText;

		private string commandPositionText;

		private string actualPositionText;

		private string commandAndActualPositionText;

		private string commandVelocityText;

		private string actualVelocityText;

		private string commandAndActualVelocityText;

		private string commandAccelerationText;

		private string actualAccelerationText;

		private string commandAndActualAccelerationText;

		private string servoCommandText;

		private string followingErrorText;

		private string commandPositionGantryFollowerText;

		private string gantryPositionText;

		private string actualVelocityGantryFollowerText;

		private string actualAccelerationGantryFollowerText;

		private string servoCommandGantryFollowerText;

		private string followingErrorGantryFollowerText;

		private string gantryFollowingErrorText;

		private string actualPositionGantryFollowerText;

		private string normalizedWrtToInitialValuesText;

		private string normalizedWrtToHomePositionText;

		private string actualCurrentText;

		private string actualCurrentResponseText;

		private string sampleTimeIsZeroText;

		private string firstDerivativeErrorText;

		private string secondDerivativeErrorText;

		private string thirdDerivativeErrorText;

		private string textFilesText;

		private string pppFilesText;

		public ChartType SetChartType = ChartType.None;

		public static CanSave CanSaveData = CanSave.NO;

		public ArrowObj Arrow;

		public GraphPane myPane;

		private Color chartBackgroundcolor = SystemColors.ControlText;

		private Color printBackgroundcolor = Color.White;

		private Color commandedposcolor = Color.IndianRed;

		private Color actualposcolor = Color.LimeGreen;

		private Color commandedvelcolor = Color.Orange;

		private Color actualvelcolor = Color.Magenta;

		private Color commandedacccolor = Color.Turquoise;

		private Color actualacccolor = Color.SeaShell;

		private Color servocomandcolor = Color.Yellow;

		private Color followingerrorcolor = Color.Silver;

		private Color gantrycommandedposcolor = Color.SandyBrown;

		private Color gantryactualposcolor = Color.SeaGreen;

		private Color gantryactualvelcolor = Color.Maroon;

		private Color gantryactualacccolor = Color.Aqua;

		private Color gantryservocomandcolor = Color.YellowGreen;

		private Color gantryfollowererrorcolor = Color.Sienna;

		private Color gantryererrorcolor = Color.White;

		public PointPair OldPointPair;

		private CurveList preFFT;

		private string preFFTXTitle;

		private string preFFTYTitle;

		private string preFFTY2Title;

		private bool skipDiag;

		public bool filtersignal;

		public bool signaldb;

		private bool _useAxisItems = true;

		private IContainer components;

		public MenuStrip menuStrip1;

		public ToolStripMenuItem toolStripMenuItem_File;

		public ToolStripMenuItem toolStripMenuItem_View;

		public ToolStripMenuItem toolStripMenuItem_Tools;

		public ToolStripMenuItem toolStripMenuItem_FFT;

		private ToolStripMenuItem openPlotDataToolStripMenuItem;

		private ToolStripMenuItem savePlotDataToolStripMenuItem;

		public ZedGraphControl zg1;

		private Panel panel1;

		private ToolStripMenuItem modifyPlotItemsToolStripMenuItem;

		private ToolStripMenuItem smoothToolStripMenuItem;

		private ToolStripMenuItem saveRawDataToolStripMenuItem;

		private ToolTip zedGraphtoolTip;

		private ToolStripSeparator toolStripSeparator1;

		private ToolStripMenuItem pageSetupToolStripMenuItem;

		private ToolStripMenuItem printPreviewToolStripMenuItem;

		private ToolStripMenuItem printToolStripMenuItem;

		public bool UseAxisItems
		{
			get
			{
				return _useAxisItems;
			}
			set
			{
				_useAxisItems = value;
			}
		}

		public event ChartFileIO ChartLoaded;

		public event ChartFileIO ChartSaved;

		public event EventHandler ChartFFTComplete;

		public PPChartControl()
		{
			InitializeComponent();
			SetLanguageTranslations();
			IApplicationSettingsService service = ServiceManager.GetService<IApplicationSettingsService>();
			DefaultPath = service.DefaultStorePath;
			SampleTime = 0.442;
			toolStripMenuItem_Tools.Enabled = false;
			INIFileName = cProperty.GetINIFile();
		}

		public PPChartControl(string openFileName)
		{
			InitializeComponent();
			SetLanguageTranslations();
			IApplicationSettingsService service = ServiceManager.GetService<IApplicationSettingsService>();
			DefaultPath = service.DefaultStorePath;
			SampleTime = 0.442;
			toolStripMenuItem_Tools.Enabled = false;
			INIFileName = cProperty.GetINIFile();
		}

		public PPChartControl(bool isTune)
		{
			istuneplot = isTune;
			InitializeComponent();
			SetLanguageTranslations();
			IApplicationSettingsService service = ServiceManager.GetService<IApplicationSettingsService>();
			DefaultPath = service.DefaultStorePath;
			SampleTime = 0.442;
			toolStripMenuItem_Tools.Enabled = false;
			INIFileName = cProperty.GetINIFile();
		}

		public void InitialChart(string Title)
		{
			zg1.IsShowHScrollBar = true;
			zg1.IsShowVScrollBar = true;
			zg1.IsAutoScrollRange = true;
			zg1.IsScrollY2 = true;
			zg1.IsEnableHZoom = true;
			zg1.IsEnableVZoom = true;
			zg1.IsEnableHPan = true;
			zg1.IsEnableVPan = true;
			zg1.IsAntiAlias = true;
			myPane = zg1.GraphPane;
			myPane.IsFontsScaled = false;
			myPane.Title.FontSpec.Size = 14f;
			myPane.XAxis.Title.FontSpec.Size = 12f;
			myPane.YAxis.Title.FontSpec.Size = 12f;
			myPane.Y2Axis.Title.FontSpec.Size = 12f;
			myPane.XAxis.Scale.FontSpec.Size = 11f;
			myPane.YAxis.Scale.FontSpec.Size = 11f;
			myPane.Y2Axis.Scale.FontSpec.Size = 11f;
			myPane.Legend.FontSpec.Size = 11f;
			myPane.Legend.FontSpec.IsAntiAlias = true;
			myPane.Legend.FontSpec.IsBold = false;
			myPane.Legend.FontSpec.IsDropShadow = false;
			myPane.Title.FontSpec.IsAntiAlias = true;
			myPane.Title.FontSpec.IsBold = false;
			myPane.Title.FontSpec.IsDropShadow = false;
			myPane.Title.Text = Title;
			myPane.XAxis.Title.FontSpec.IsAntiAlias = true;
			myPane.XAxis.Title.FontSpec.IsBold = false;
			myPane.XAxis.Title.FontSpec.IsDropShadow = false;
			myPane.XAxis.Title.Text = timeMillisecondsText;
			myPane.YAxis.Title.FontSpec.IsAntiAlias = true;
			myPane.YAxis.Title.FontSpec.IsBold = false;
			myPane.YAxis.Title.FontSpec.IsDropShadow = false;
			myPane.YAxis.Title.Text = positionText;
			myPane.Y2Axis.Title.FontSpec.IsBold = false;
			myPane.Y2Axis.Title.FontSpec.IsDropShadow = false;
			myPane.Y2Axis.Title.Text = positionText;
			myPane.Y2Axis.Title.Text = "";
			myPane.XAxis.Scale.MinGrace = 0.0;
			myPane.XAxis.Scale.MaxGrace = 0.0;
			myPane.Y2Axis.MajorTic.IsOpposite = false;
			myPane.Y2Axis.MinorTic.IsOpposite = false;
			myPane.X2Axis.MajorTic.IsOpposite = false;
			myPane.X2Axis.MinorTic.IsOpposite = false;
			myPane.YAxis.MajorGrid.IsZeroLine = false;
			myPane.XAxis.MajorGrid.IsZeroLine = false;
			myPane.Y2Axis.MajorGrid.IsZeroLine = false;
			myPane.X2Axis.MajorGrid.IsZeroLine = false;
			myPane.Y2Axis.Scale.Align = AlignP.Inside;
			myPane.X2Axis.Scale.Align = AlignP.Inside;
			myPane.YAxis.MajorGrid.IsVisible = true;
			zg1.IsShowPointValues = true;
			zg1.PointValueEvent -= MyPointValueHandler;
			zg1.PointValueEvent += MyPointValueHandler;
			zg1.ContextMenuBuilder -= MyContextMenuBuilder;
			zg1.ContextMenuBuilder += MyContextMenuBuilder;
			zg1.ZoomEvent -= MyZoomEvent;
			zg1.ZoomEvent += MyZoomEvent;
			SetSize();
			if (File.Exists(INIFileName) & !istuneplot)
			{
				RestoreGraphPhane(INIFileName);
			}
			zg1.AxisChange();
			zg1.Invalidate();
		}

		public void SetChart(string Title)
		{
			Cursor = Cursors.WaitCursor;
			Cursor = Cursors.Default;
			SoapDeSerialize(zg1, Title);
			SetSize();
			Form form = new Form();
			form.Icon = Resources.ApplicationIcon;
			form.ShowIcon = true;
			form.Size = new Size(510, 410);
			form.TopMost = false;
			form.StartPosition = FormStartPosition.CenterScreen;
			form.Controls.Add(zg1);
			if (form != null)
			{
				form.Text = Title;
			}
			form.Show();
		}

		public void SetAllChartColor(Color backcolor, Color forecolor)
		{
			myPane.Fill = new Fill(backcolor);
			myPane.Chart.Fill = new Fill(backcolor);
			myPane.YAxis.MajorTic.Color = forecolor;
			myPane.YAxis.MinorTic.Color = forecolor;
			myPane.XAxis.MajorTic.Color = forecolor;
			myPane.XAxis.MinorTic.Color = forecolor;
			myPane.Title.FontSpec.FontColor = forecolor;
			myPane.XAxis.Title.FontSpec.FontColor = forecolor;
			myPane.YAxis.Title.FontSpec.FontColor = forecolor;
			myPane.Y2Axis.Title.FontSpec.FontColor = forecolor;
			myPane.XAxis.Color = forecolor;
			myPane.YAxis.Color = forecolor;
			myPane.Y2Axis.Color = forecolor;
			myPane.XAxis.Scale.FontSpec.FontColor = forecolor;
			myPane.YAxis.Scale.FontSpec.FontColor = forecolor;
			myPane.Y2Axis.Scale.FontSpec.FontColor = forecolor;
			myPane.XAxis.MajorGrid.Color = forecolor;
			myPane.YAxis.MajorGrid.Color = forecolor;
			myPane.Y2Axis.MajorGrid.Color = forecolor;
			myPane.Chart.Border.Color = forecolor;
		}

		public bool RestoreGraphPhane(string file)
		{
			INI_ReadWrite iNI_ReadWrite = new INI_ReadWrite(file);
			myPane = zg1.GraphPane;
			if (!File.Exists(iNI_ReadWrite.path))
			{
				return false;
			}
			ColorConverter colorConverter = new ColorConverter();
			if (((Color)colorConverter.ConvertFromString(iNI_ReadWrite.IniReadValue("Chart Settings", "Chart Background"))).Name == "White")
			{
				SetChartColor(Color.White, SystemColors.ControlText);
			}
			else
			{
				SetChartColor(SystemColors.ControlText, Color.White);
			}
			string text = iNI_ReadWrite.IniReadValue("Chart Settings", "Title");
			myPane.Title.Text = (string.IsNullOrEmpty(text) ? $"{productNameText} {plotText}" : text);
			myPane.Title.IsVisible = true;
			colorConverter = new ColorConverter();
			Color fontColor = (Color)colorConverter.ConvertFromString(iNI_ReadWrite.IniReadValue("Chart Settings", "Title ForeColor"));
			if (fontColor.Name == "0")
			{
				myPane.Title.FontSpec.FontColor = (Color)colorConverter.ConvertFromString("White");
			}
			else
			{
				myPane.Title.FontSpec.FontColor = fontColor;
			}
			string text2 = iNI_ReadWrite.IniReadValue("X Axis", "Show XAxis");
			if (text2 == "")
			{
				myPane.XAxis.IsVisible = true;
			}
			else
			{
				myPane.XAxis.IsVisible = Convert.ToBoolean(text2);
			}
			Color fontColor2 = (Color)colorConverter.ConvertFromString(iNI_ReadWrite.IniReadValue("X Axis", "XAxis Title Color"));
			if (fontColor2.Name == "0")
			{
				myPane.XAxis.Title.FontSpec.FontColor = (Color)colorConverter.ConvertFromString("White");
			}
			else
			{
				myPane.XAxis.Title.FontSpec.FontColor = fontColor2;
			}
			string text3 = iNI_ReadWrite.IniReadValue("X Axis", "XAxis Title");
			SetXAxisTitle(string.IsNullOrEmpty(text3) ? timeSecondsText : text3);
			string value = iNI_ReadWrite.IniReadValue("X Axis", "XAxis Decimals");
			if (string.IsNullOrEmpty(value))
			{
				myPane.XAxis.Scale.Format = "f2";
			}
			else
			{
				myPane.XAxis.Scale.Format = "f" + iNI_ReadWrite.IniReadValue("X Axis", "XAxis Decimals");
			}
			string value2 = iNI_ReadWrite.IniReadValue("X Axis", "XAxis Minimum");
			if (!string.IsNullOrEmpty(value2))
			{
				myPane.XAxis.Scale.Min = Convert.ToDouble(value2);
			}
			string value3 = iNI_ReadWrite.IniReadValue("X Axis", "XAxis Maximum");
			if (!string.IsNullOrEmpty(value3))
			{
				myPane.XAxis.Scale.Max = Convert.ToDouble(value3);
			}
			string value4 = iNI_ReadWrite.IniReadValue("X Axis", "XAxis MinorUnit");
			if (!string.IsNullOrEmpty(value4))
			{
				myPane.XAxis.Scale.MinorStep = Convert.ToDouble(value4);
			}
			string value5 = iNI_ReadWrite.IniReadValue("X Axis", "XAxis MajorUnit");
			if (!string.IsNullOrEmpty(value5))
			{
				myPane.XAxis.Scale.MajorStep = Convert.ToDouble(value5);
			}
			if (iNI_ReadWrite.IniReadValue("X Axis", "XAxis Unit Display Type").Equals("Standard"))
			{
				myPane.XAxis.Scale.MagAuto = false;
			}
			else
			{
				myPane.XAxis.Scale.MagAuto = true;
			}
			Color color = (Color)colorConverter.ConvertFromString(iNI_ReadWrite.IniReadValue("X Axis", "XAxis MajorGridLineColor"));
			if (color.Name == "0")
			{
				myPane.XAxis.MajorGrid.Color = (Color)colorConverter.ConvertFromString("White");
			}
			else
			{
				myPane.XAxis.MajorGrid.Color = color;
			}
			Color color2 = (Color)colorConverter.ConvertFromString(iNI_ReadWrite.IniReadValue("X Axis", "XAxis MinorGridLineColor"));
			if (color2.Name == "0")
			{
				myPane.XAxis.MinorGrid.Color = (Color)colorConverter.ConvertFromString("White");
			}
			else
			{
				myPane.XAxis.MinorGrid.Color = color2;
			}
			if (string.IsNullOrEmpty(iNI_ReadWrite.IniReadValue("X Axis", "XAxis MajorGridLineWidth")))
			{
				myPane.XAxis.MajorGrid.PenWidth = 1f;
			}
			else
			{
				myPane.XAxis.MajorGrid.PenWidth = float.Parse(iNI_ReadWrite.IniReadValue("X Axis", "XAxis MajorGridLineWidth"));
			}
			if (string.IsNullOrEmpty(iNI_ReadWrite.IniReadValue("X Axis", "XAxis MinorGridLineWidth")))
			{
				myPane.XAxis.MinorGrid.PenWidth = 1f;
			}
			else
			{
				myPane.XAxis.MinorGrid.PenWidth = float.Parse(iNI_ReadWrite.IniReadValue("X Axis", "XAxis MinorGridLineWidth"));
			}
			text2 = iNI_ReadWrite.IniReadValue("Y Axis", "Show YAxis");
			if (text2 == "")
			{
				myPane.YAxis.IsVisible = true;
			}
			else
			{
				myPane.YAxis.IsVisible = Convert.ToBoolean(text2);
			}
			Color fontColor3 = (Color)colorConverter.ConvertFromString(iNI_ReadWrite.IniReadValue("Y Axis", "YAxis Title Color"));
			if (fontColor3.Name == "0")
			{
				myPane.YAxis.Title.FontSpec.FontColor = (Color)colorConverter.ConvertFromString("White");
			}
			else
			{
				myPane.YAxis.Title.FontSpec.FontColor = fontColor3;
			}
			string text4 = iNI_ReadWrite.IniReadValue("Y Axis", "YAxis Title");
			if (text4 == "")
			{
				myPane.YAxis.Title.Text = "";
			}
			else
			{
				myPane.YAxis.Title.Text = text4;
			}
			string text5 = iNI_ReadWrite.IniReadValue("Y Axis", "YAxis Decimals");
			if (string.IsNullOrEmpty(text5))
			{
				myPane.YAxis.Scale.Format = "f2";
			}
			else
			{
				myPane.YAxis.Scale.Format = "f" + text5;
			}
			value2 = iNI_ReadWrite.IniReadValue("Y Axis", "YAxis Minimum");
			if (!string.IsNullOrEmpty(value2))
			{
				myPane.YAxis.Scale.Min = Convert.ToDouble(value2);
			}
			value3 = iNI_ReadWrite.IniReadValue("Y Axis", "YAxis Maximum");
			if (!string.IsNullOrEmpty(value3))
			{
				myPane.YAxis.Scale.Max = Convert.ToDouble(value3);
			}
			value4 = iNI_ReadWrite.IniReadValue("Y Axis", "YAxis MinorUnit");
			if (!string.IsNullOrEmpty(value4))
			{
				myPane.YAxis.Scale.MinorStep = Convert.ToDouble(value4);
			}
			value5 = iNI_ReadWrite.IniReadValue("Y Axis", "YAxis MajorUnit");
			if (!string.IsNullOrEmpty(value5))
			{
				myPane.YAxis.Scale.MajorStep = Convert.ToDouble(value5);
			}
			if (iNI_ReadWrite.IniReadValue("Y Axis", "YAxis Unit Display Type").Equals("Standard"))
			{
				myPane.YAxis.Scale.MagAuto = false;
			}
			else
			{
				myPane.YAxis.Scale.MagAuto = true;
			}
			Color color3 = (Color)colorConverter.ConvertFromString(iNI_ReadWrite.IniReadValue("Y Axis", "YAxis MajorGridLineColor"));
			if (color.Name == "0")
			{
				myPane.YAxis.MajorGrid.Color = (Color)colorConverter.ConvertFromString("White");
			}
			else
			{
				myPane.YAxis.MajorGrid.Color = color3;
			}
			Color color6 = (Color)colorConverter.ConvertFromString(iNI_ReadWrite.IniReadValue("Y Axis", "YAxis MinorGridLineColor"));
			if (color2.Name == "0")
			{
				myPane.YAxis.MinorGrid.Color = (Color)colorConverter.ConvertFromString("White");
			}
			else
			{
				myPane.YAxis.MinorGrid.Color = color2;
			}
			if (string.IsNullOrEmpty(iNI_ReadWrite.IniReadValue("Y Axis", "YAxis MajorGridLineWidth")))
			{
				myPane.YAxis.MajorGrid.PenWidth = 1f;
			}
			else
			{
				myPane.YAxis.MajorGrid.PenWidth = float.Parse(iNI_ReadWrite.IniReadValue("Y Axis", "YAxis MajorGridLineWidth"));
			}
			if (string.IsNullOrEmpty(iNI_ReadWrite.IniReadValue("Y Axis", "YAxis MinorGridLineWidth")))
			{
				myPane.YAxis.MinorGrid.PenWidth = 1f;
			}
			else
			{
				myPane.YAxis.MinorGrid.PenWidth = float.Parse(iNI_ReadWrite.IniReadValue("Y Axis", "YAxis MinorGridLineWidth"));
			}
			text2 = iNI_ReadWrite.IniReadValue("Y2 Axis", "Show Y2Axis");
			if (text2 == "")
			{
				myPane.Y2Axis.IsVisible = true;
			}
			else
			{
				myPane.Y2Axis.IsVisible = Convert.ToBoolean(text2);
			}
			Color fontColor4 = (Color)colorConverter.ConvertFromString(iNI_ReadWrite.IniReadValue("Y2 Axis", "Y2Axis Title Color"));
			if (fontColor4.Name == "0")
			{
				myPane.Y2Axis.Title.FontSpec.FontColor = (Color)colorConverter.ConvertFromString("White");
			}
			else
			{
				myPane.Y2Axis.Title.FontSpec.FontColor = fontColor4;
			}
			string text6 = iNI_ReadWrite.IniReadValue("Y2 Axis", "Y2Axis Title");
			if (text6 == "")
			{
				myPane.Y2Axis.Title.Text = "";
			}
			else
			{
				myPane.Y2Axis.Title.Text = text6;
			}
			string text7 = iNI_ReadWrite.IniReadValue("Y2 Axis", "Y2Axis Decimals");
			if (string.IsNullOrEmpty(value))
			{
				myPane.Y2Axis.Scale.Format = "f2";
			}
			else
			{
				myPane.Y2Axis.Scale.Format = "f" + text7;
			}
			value2 = iNI_ReadWrite.IniReadValue("Y2 Axis", "Y2Axis Minimum");
			if (!string.IsNullOrEmpty(value2))
			{
				myPane.Y2Axis.Scale.Min = Convert.ToDouble(value2);
			}
			value3 = iNI_ReadWrite.IniReadValue("Y2 Axis", "Y2Axis Maximum");
			if (!string.IsNullOrEmpty(value3))
			{
				myPane.Y2Axis.Scale.Max = Convert.ToDouble(value3);
			}
			value4 = iNI_ReadWrite.IniReadValue("Y2 Axis", "Y2Axis MinorUnit");
			if (!string.IsNullOrEmpty(value4))
			{
				myPane.Y2Axis.Scale.MinorStep = Convert.ToDouble(value4);
			}
			value5 = iNI_ReadWrite.IniReadValue("Y2 Axis", "Y2Axis MajorUnit");
			if (!string.IsNullOrEmpty(value5))
			{
				myPane.Y2Axis.Scale.MajorStep = Convert.ToDouble(value5);
			}
			if (iNI_ReadWrite.IniReadValue("Y2 Axis", "Y2Axis Unit Display Type").Equals("Standard"))
			{
				myPane.Y2Axis.Scale.MagAuto = false;
			}
			else
			{
				myPane.Y2Axis.Scale.MagAuto = true;
			}
			Color color4 = (Color)colorConverter.ConvertFromString(iNI_ReadWrite.IniReadValue("Y2 Axis", "Y2Axis MajorGridLineColor"));
			if (color4.Name == "0")
			{
				myPane.Y2Axis.MajorGrid.Color = (Color)colorConverter.ConvertFromString("White");
			}
			else
			{
				myPane.Y2Axis.MajorGrid.Color = color4;
			}
			Color color5 = (Color)colorConverter.ConvertFromString(iNI_ReadWrite.IniReadValue("Y2 Axis", "Y2Axis MinorGridLineColor"));
			if (color5.Name == "0")
			{
				myPane.Y2Axis.MinorGrid.Color = (Color)colorConverter.ConvertFromString("White");
			}
			else
			{
				myPane.Y2Axis.MinorGrid.Color = color5;
			}
			if (string.IsNullOrEmpty(iNI_ReadWrite.IniReadValue("Y2 Axis", "Y2Axis MajorGridLineWidth")))
			{
				myPane.Y2Axis.MajorGrid.PenWidth = 1f;
			}
			else
			{
				myPane.Y2Axis.MajorGrid.PenWidth = float.Parse(iNI_ReadWrite.IniReadValue("Y2 Axis", "Y2Axis MajorGridLineWidth"));
			}
			if (string.IsNullOrEmpty(iNI_ReadWrite.IniReadValue("Y2 Axis", "Y2Axis MinorGridLineWidth")))
			{
				myPane.Y2Axis.MinorGrid.PenWidth = 1f;
			}
			else
			{
				myPane.Y2Axis.MinorGrid.PenWidth = float.Parse(iNI_ReadWrite.IniReadValue("Y2 Axis", "Y2Axis MinorGridLineWidth"));
			}
			zg1.AxisChange();
			zg1.Invalidate();
			return true;
		}

		public void SetChartColor(Color backcolor, Color forecolor)
		{
			if (myPane == null)
			{
				myPane = zg1.GraphPane;
			}
			myPane.Fill = new Fill(backcolor);
			myPane.Chart.Fill = new Fill(backcolor);
			myPane.YAxis.MajorTic.Color = forecolor;
			myPane.YAxis.MinorTic.Color = forecolor;
			myPane.XAxis.MajorTic.Color = forecolor;
			myPane.XAxis.MinorTic.Color = forecolor;
			myPane.XAxis.Color = forecolor;
			myPane.YAxis.Color = forecolor;
			myPane.Y2Axis.Color = forecolor;
			myPane.XAxis.Scale.FontSpec.FontColor = forecolor;
			myPane.YAxis.Scale.FontSpec.FontColor = forecolor;
			myPane.Y2Axis.Scale.FontSpec.FontColor = forecolor;
			if (backcolor == SystemColors.ControlText)
			{
				if (myPane.Title.FontSpec.FontColor == SystemColors.ControlText || myPane.Title.FontSpec.FontColor == Color.Black)
				{
					myPane.Title.FontSpec.FontColor = Color.White;
				}
				if (myPane.XAxis.Title.FontSpec.FontColor == SystemColors.ControlText || myPane.XAxis.Title.FontSpec.FontColor == Color.Black)
				{
					myPane.XAxis.Title.FontSpec.FontColor = Color.White;
				}
				if (myPane.YAxis.Title.FontSpec.FontColor == SystemColors.ControlText || myPane.YAxis.Title.FontSpec.FontColor == Color.Black)
				{
					myPane.YAxis.Title.FontSpec.FontColor = Color.White;
				}
				if (myPane.Y2Axis.Title.FontSpec.FontColor == SystemColors.ControlText || myPane.Y2Axis.Title.FontSpec.FontColor == Color.Black)
				{
					myPane.Y2Axis.Title.FontSpec.FontColor = Color.White;
				}
				if (myPane.XAxis.MajorGrid.Color == SystemColors.ControlText || myPane.XAxis.MajorGrid.Color == Color.Black)
				{
					myPane.XAxis.MajorGrid.Color = Color.White;
				}
				if (myPane.YAxis.MajorGrid.Color == SystemColors.ControlText || myPane.YAxis.MajorGrid.Color == Color.Black)
				{
					myPane.YAxis.MajorGrid.Color = Color.White;
				}
				if (myPane.Y2Axis.MajorGrid.Color == SystemColors.ControlText || myPane.Y2Axis.MajorGrid.Color == Color.Black)
				{
					myPane.Y2Axis.MajorGrid.Color = Color.White;
				}
			}
			else
			{
				if (myPane.Title.FontSpec.FontColor == Color.White)
				{
					myPane.Title.FontSpec.FontColor = SystemColors.ControlText;
				}
				if (myPane.XAxis.Title.FontSpec.FontColor == Color.White)
				{
					myPane.XAxis.Title.FontSpec.FontColor = SystemColors.ControlText;
				}
				if (myPane.YAxis.Title.FontSpec.FontColor == Color.White)
				{
					myPane.YAxis.Title.FontSpec.FontColor = SystemColors.ControlText;
				}
				if (myPane.Y2Axis.Title.FontSpec.FontColor == Color.White)
				{
					myPane.Y2Axis.Title.FontSpec.FontColor = SystemColors.ControlText;
				}
				if (myPane.XAxis.MajorGrid.Color == Color.White)
				{
					myPane.XAxis.MajorGrid.Color = Color.Gray;
				}
				if (myPane.YAxis.MajorGrid.Color == Color.White)
				{
					myPane.YAxis.MajorGrid.Color = Color.Gray;
				}
				if (myPane.Y2Axis.MajorGrid.Color == Color.White)
				{
					myPane.Y2Axis.MajorGrid.Color = Color.Gray;
				}
			}
			myPane.Chart.Border.Color = forecolor;
		}

		public void SetSize()
		{
			zg1.Location = new Point(10, 10);
			zg1.Size = new Size(base.ClientRectangle.Width - 20, base.ClientRectangle.Height - 20);
			zg1.AxisChange();
		}

		private void SetChartDetails()
		{
			ColorConverter colorConverter = new ColorConverter();
			NumberFormatInfo numberFormatInfo = new NumberFormatInfo();
			numberFormatInfo.NumberDecimalDigits = 4;
			_plotdetails.Title = myPane.Title.Text;
			_plotdetails.TitleFont = myPane.Title.FontSpec.Family + ", " + myPane.Title.FontSpec.Size + "pt";
			_plotdetails.TitleForeColor = colorConverter.ConvertToString(myPane.Title.FontSpec.FontColor);
			_plotdetails.ChartBackground = colorConverter.ConvertToString(myPane.Chart.Fill.Color);
			_plotdetails.ShowXAxis = myPane.XAxis.IsVisible.ToString();
			_plotdetails.XAxisTitleFont = myPane.XAxis.Title.FontSpec.Family + ", " + myPane.XAxis.Title.FontSpec.Size + "pt";
			_plotdetails.XAxisTitleColor = colorConverter.ConvertToString(myPane.XAxis.Title.FontSpec.FontColor);
			_plotdetails.XAxisTitle = myPane.XAxis.Title.Text;
			_plotdetails.XAxisShowMajorGridLine = myPane.XAxis.MajorGrid.IsVisible.ToString();
			_plotdetails.XAxisShowMinorGridLine = myPane.XAxis.MinorGrid.IsVisible.ToString();
			_plotdetails.XAxisMajorUnit = myPane.XAxis.Scale.MajorStep.ToString("N", numberFormatInfo);
			_plotdetails.XAxisMinorUnit = myPane.XAxis.Scale.MinorStep.ToString("N", numberFormatInfo);
			_plotdetails.XAxisDecimals = myPane.XAxis.Scale.Format.TrimStart('f');
			if (myPane.XAxis.Scale.MagAuto)
			{
				_plotdetails.XAxisUnitDisplayType = "Scientific";
			}
			else
			{
				_plotdetails.XAxisUnitDisplayType = "Standard";
			}
			_plotdetails.XAxisMajorGridLineColor = colorConverter.ConvertToString(myPane.XAxis.MajorGrid.Color);
			_plotdetails.XAxisMajorGridLineWidth = myPane.XAxis.MajorGrid.PenWidth.ToString();
			_plotdetails.XAxisMinorGridLineColor = colorConverter.ConvertToString(myPane.XAxis.MinorGrid.Color);
			_plotdetails.XAxisMinorGridLineWidth = myPane.XAxis.MinorGrid.PenWidth.ToString();
			_plotdetails.ShowYAxis = myPane.YAxis.IsVisible.ToString();
			_plotdetails.YAxisTitleFont = myPane.YAxis.Title.FontSpec.Family + ", " + myPane.YAxis.Title.FontSpec.Size + "pt";
			_plotdetails.YAxisTitleColor = colorConverter.ConvertToString(myPane.YAxis.Title.FontSpec.FontColor);
			_plotdetails.YAxisTitle = myPane.YAxis.Title.Text;
			_plotdetails.YAxisShowMajorGridLine = myPane.YAxis.MajorGrid.IsVisible.ToString();
			_plotdetails.YAxisShowMinorGridLine = myPane.YAxis.MinorGrid.IsVisible.ToString();
			_plotdetails.YAxisMajorUnit = myPane.YAxis.Scale.MajorStep.ToString("N", numberFormatInfo);
			_plotdetails.YAxisMinorUnit = myPane.YAxis.Scale.MinorStep.ToString("N", numberFormatInfo);
			_plotdetails.YAxisDecimals = myPane.YAxis.Scale.Format.TrimStart('f');
			if (myPane.YAxis.Scale.MagAuto)
			{
				_plotdetails.YAxisUnitDisplayType = "Scientific";
			}
			else
			{
				_plotdetails.YAxisUnitDisplayType = "Standard";
			}
			_plotdetails.YAxisMajorGridLineColor = colorConverter.ConvertToString(myPane.YAxis.MajorGrid.Color);
			_plotdetails.YAxisMajorGridLineWidth = myPane.YAxis.MajorGrid.PenWidth.ToString();
			_plotdetails.YAxisMinorGridLineColor = colorConverter.ConvertToString(myPane.YAxis.MinorGrid.Color);
			_plotdetails.YAxisMinorGridLineWidth = myPane.YAxis.MinorGrid.PenWidth.ToString();
			_plotdetails.ShowY2Axis = myPane.Y2Axis.IsVisible.ToString();
			_plotdetails.Y2AxisTitleFont = myPane.Y2Axis.Title.FontSpec.Family + ", " + myPane.Y2Axis.Title.FontSpec.Size + "pt";
			_plotdetails.Y2AxisTitleColor = colorConverter.ConvertToString(myPane.Y2Axis.Title.FontSpec.FontColor);
			_plotdetails.Y2AxisTitle = myPane.Y2Axis.Title.Text;
			_plotdetails.Y2AxisShowMajorGridLine = myPane.Y2Axis.MajorGrid.IsVisible.ToString();
			_plotdetails.Y2AxisShowMinorGridLine = myPane.Y2Axis.MinorGrid.IsVisible.ToString();
			_plotdetails.Y2AxisMajorUnit = myPane.Y2Axis.Scale.MajorStep.ToString("N", numberFormatInfo);
			_plotdetails.Y2AxisMinorUnit = myPane.Y2Axis.Scale.MinorStep.ToString("N", numberFormatInfo);
			_plotdetails.Y2AxisDecimals = myPane.Y2Axis.Scale.Format.TrimStart('f');
			if (myPane.Y2Axis.Scale.MagAuto)
			{
				_plotdetails.Y2AxisUnitDisplayType = "Scientific";
			}
			else
			{
				_plotdetails.Y2AxisUnitDisplayType = "Standard";
			}
			_plotdetails.Y2AxisMajorGridLineColor = colorConverter.ConvertToString(myPane.Y2Axis.MajorGrid.Color);
			_plotdetails.Y2AxisMajorGridLineWidth = myPane.Y2Axis.MajorGrid.PenWidth.ToString();
			_plotdetails.Y2AxisMinorGridLineColor = colorConverter.ConvertToString(myPane.Y2Axis.MinorGrid.Color);
			_plotdetails.Y2AxisMinorGridLineWidth = myPane.Y2Axis.MinorGrid.PenWidth.ToString();
		}

		private string MyPointValueHandler(ZedGraphControl control, GraphPane pane, CurveItem curve, int iPt)
		{
			PointPair pointPair = curve[iPt];
			if (OldPointPair != pointPair)
			{
				zedGraphtoolTip.SetToolTip(control, string.Format(CultureInfo.CurrentUICulture, graphToolTipTextFormat, curve.Label.Text, pointPair.Y.ToString("f6"), pointPair.X.ToString("f4")));
			}
			OldPointPair = pointPair;
			return null;
		}

		private void MyContextMenuBuilder(ZedGraphControl control, ContextMenuStrip menuStrip, Point mousePt, ZedGraphControl.ContextMenuObjectState objState)
		{
			ToolStripMenuItem toolStripMenuItem = new ToolStripMenuItem();
			int num = menuStrip.Items.IndexOfKey("Print");
			int num2 = menuStrip.Items.IndexOfKey("page_setup");
			if (num >= 0)
			{
				menuStrip.Items.RemoveAt(num);
			}
			if (num2 >= 0)
			{
				menuStrip.Items.RemoveAt(num2);
			}
			ToolStripMenuItem toolStripMenuItem2 = new ToolStripMenuItem();
			toolStripMenuItem2.Name = "Page Setup";
			toolStripMenuItem2.Tag = "Page Setup";
			toolStripMenuItem2.Text = pageSetupText;
			toolStripMenuItem2.Click += PageSetupItem_Click;
			menuStrip.Items.Add(toolStripMenuItem2);
			ToolStripMenuItem toolStripMenuItem3 = new ToolStripMenuItem();
			toolStripMenuItem3.Name = "Print Preview";
			toolStripMenuItem3.Tag = "Print Preview";
			toolStripMenuItem3.Text = printPreviewText;
			toolStripMenuItem3.Click += PrintPreviewItem_Click;
			menuStrip.Items.Add(toolStripMenuItem3);
			ToolStripMenuItem toolStripMenuItem4 = new ToolStripMenuItem();
			toolStripMenuItem4.Name = "Print";
			toolStripMenuItem4.Tag = "Print";
			toolStripMenuItem4.Text = printText;
			toolStripMenuItem4.Click += printItem_Click;
			menuStrip.Items.Add(toolStripMenuItem4);
			toolStripMenuItem.Name = "Property";
			toolStripMenuItem.Tag = "Property";
			toolStripMenuItem.Text = propertiesText;
			toolStripMenuItem.Click += OpenProperty;
			menuStrip.Items.Add(toolStripMenuItem);
			foreach (ToolStripMenuItem item in menuStrip.Items)
			{
				if ((string)item.Tag == "set_default")
				{
					menuStrip.Items.Remove(item);
					break;
				}
			}
			ToolStripMenuItem toolStripMenuItem6 = new ToolStripMenuItem();
			toolStripMenuItem6.Name = "Set Scale to Default";
			toolStripMenuItem6.Tag = "Set Scale to Default";
			toolStripMenuItem6.Text = setScaleToDefaultText;
			toolStripMenuItem6.Click += wrappedSetScaleToDefault_Click;
			menuStrip.Items.Add(toolStripMenuItem6);
		}

		public void wrappedSetScaleToDefault_Click(object sender, EventArgs e)
		{
			INI_ReadWrite iNI_ReadWrite = new INI_ReadWrite(new FormProperty(istuneplot).GetINIFile());
			iNI_ReadWrite.IniWriteValue("X Axis", "XAxis Minimum", string.Empty);
			iNI_ReadWrite.IniWriteValue("X Axis", "XAxis Maximum", string.Empty);
			iNI_ReadWrite.IniWriteValue("X Axis", "XAxis MinorUnit", string.Empty);
			iNI_ReadWrite.IniWriteValue("X Axis", "XAxis MajorUnit", string.Empty);
			iNI_ReadWrite.IniWriteValue("Y Axis", "YAxis Minimum", string.Empty);
			iNI_ReadWrite.IniWriteValue("Y Axis", "YAxis Maximum", string.Empty);
			iNI_ReadWrite.IniWriteValue("Y Axis", "YAxis MinorUnit", string.Empty);
			iNI_ReadWrite.IniWriteValue("Y Axis", "YAxis MajorUnit", string.Empty);
			iNI_ReadWrite.IniWriteValue("Y2 Axis", "Y2Axis Minimum", string.Empty);
			iNI_ReadWrite.IniWriteValue("Y2 Axis", "Y2Axis Maximum", string.Empty);
			iNI_ReadWrite.IniWriteValue("Y2 Axis", "Y2Axis MinorUnit", string.Empty);
			iNI_ReadWrite.IniWriteValue("Y2 Axis", "Y2Axis MajorUnit", string.Empty);
			zg1.RestoreScale(zg1.GraphPane);
		}

		private void AddBetaPoint(object sender, EventArgs args)
		{
			addpoint();
		}

		private void addpoint()
		{
			IPointListEdit pointListEdit = zg1.GraphPane.CurveList["Beta"].Points as IPointListEdit;
			IPointList point = zg1.GraphPane.CurveList["Beta"].Points;
			if (pointListEdit != null)
			{
				double num = (double)pointListEdit.Count * 5.0;
				double num2 = Math.Sin((double)pointListEdit.Count * Math.PI / 15.0) * 16.0 * 13.5;
				pointListEdit.Add(num, num2);
				pointListEdit.Add(xy.Pop());
				zg1.AxisChange();
				zg1.Refresh();
			}
		}

		public void InitialRealTimeChart(string Title)
		{
			myPane = zg1.GraphPane;
			myPane.Title.Text = Title;
			myPane.XAxis.Title.Text = timeMillisecondsText;
			myPane.YAxis.Title.Text = "";
			myPane.Y2Axis.Title.Text = "";
			myPane.YAxis.Scale.MagAuto = false;
			myPane.YAxis.MajorTic.IsOpposite = false;
			myPane.YAxis.MinorTic.IsOpposite = false;
			myPane.YAxis.MajorGrid.IsZeroLine = true;
			myPane.YAxis.MajorGrid.IsVisible = true;
			myPane.YAxis.MajorTic.Color = Color.White;
			myPane.YAxis.MinorTic.Color = Color.White;
			myPane.YAxis.Title.FontSpec.FontColor = Color.White;
			myPane.YAxis.Color = Color.White;
			myPane.YAxis.Scale.FontSpec.FontColor = Color.White;
			myPane.YAxis.MajorGrid.Color = Color.White;
			myPane.YAxis.Scale.Min = -100.0;
			myPane.YAxis.Scale.Max = 100.0;
			myPane.YAxis.Scale.MajorUnit = DateUnit.Millisecond;
			myPane.YAxis.Scale.MajorStep = 20.0;
			myPane.XAxis.MajorTic.IsOpposite = true;
			myPane.XAxis.MinorTic.IsOpposite = true;
			myPane.XAxis.MajorGrid.IsZeroLine = true;
			myPane.XAxis.MajorTic.Color = Color.White;
			myPane.XAxis.MinorTic.Color = Color.White;
			myPane.XAxis.Title.FontSpec.FontColor = Color.White;
			myPane.XAxis.Color = Color.White;
			myPane.XAxis.Scale.FontSpec.FontColor = Color.White;
			myPane.XAxis.MajorGrid.Color = Color.White;
			myPane.XAxis.Scale.Min = -100.0;
			myPane.XAxis.Scale.Max = 100.0;
			myPane.XAxis.Scale.MajorUnit = DateUnit.Millisecond;
			myPane.XAxis.Scale.MajorStep = 20.0;
			myPane.XAxis.MajorGrid.IsVisible = true;
			myPane.XAxis.Scale.IsVisible = true;
			Arrow = new ArrowObj(Color.Red, 2f, 0.0, 0.0, 0.0, 1.0);
			Arrow.Location.CoordinateFrame = CoordType.XScaleYChartFraction;
			Arrow.ZOrder = ZOrder.A_InFront;
			myPane.GraphObjList.Add(Arrow);
			myPane.Y2Axis.MajorTic.IsOpposite = false;
			myPane.Y2Axis.MinorTic.IsOpposite = false;
			myPane.Y2Axis.MajorGrid.IsZeroLine = false;
			myPane.Y2Axis.Scale.Align = AlignP.Inside;
			myPane.Y2Axis.Title.FontSpec.FontColor = Color.White;
			myPane.Y2Axis.Color = Color.White;
			myPane.Y2Axis.Scale.FontSpec.FontColor = Color.White;
			myPane.Y2Axis.MajorGrid.Color = Color.White;
			myPane.X2Axis.MajorTic.IsOpposite = false;
			myPane.X2Axis.MinorTic.IsOpposite = false;
			myPane.X2Axis.MajorGrid.IsZeroLine = false;
			myPane.X2Axis.Scale.Align = AlignP.Inside;
			zg1.IsShowHScrollBar = false;
			zg1.IsShowVScrollBar = false;
			zg1.IsAutoScrollRange = true;
			zg1.IsScrollY2 = false;
			myPane.Title.FontSpec.FontColor = Color.White;
			myPane.Chart.Border.Color = Color.White;
			myPane.Chart.Fill = new Fill(Color.Black, Color.FromArgb(0, 0, 89), 90f);
			myPane.Fill = new Fill(Color.FromArgb(5, 5, 0));
			zg1.IsShowPointValues = true;
			zg1.PointValueEvent += MyPointValueHandler;
			zg1.ContextMenuBuilder += MyContextMenuBuilder;
			zg1.ZoomEvent += MyZoomEvent;
			SetSize();
			zg1.AxisChange();
			zg1.Invalidate();
		}

		public void ClearChart()
		{
			zg1.MasterPane = new MasterPane();
		}

		public void ClearCurveList()
		{
			zg1.GraphPane.CurveList.Clear();
		}

		public void ClearGraphObjList()
		{
			zg1.GraphPane.GraphObjList.Clear();
		}

		public void CallLogo()
		{
		}

		public void CallTitle(string title)
		{
			zg1.GraphPane.Title.Text = title;
		}

		public void CallXAxisTitle(string title)
		{
			SetXAxisTitle(title);
		}

		public void CallXAxisScale(int UnitDiv)
		{
			zg1.GraphPane.XAxis.Scale.Min = -5 * UnitDiv;
			zg1.GraphPane.XAxis.Scale.Max = 5 * UnitDiv;
			zg1.GraphPane.XAxis.Scale.MajorStep = UnitDiv;
		}

		public void CallXAxisScaleVisible(bool IsVisible)
		{
			zg1.GraphPane.XAxis.Scale.IsVisible = IsVisible;
		}

		public void CallArrowPosition(int Offset)
		{
			Arrow.Location.X1 = Offset;
			Arrow.ZOrder = ZOrder.F_BehindGrid;
		}

		public void CallYAxisTitle(string title)
		{
			zg1.GraphPane.YAxis.Title.Text = title;
		}

		public void SetAutoScale(bool status)
		{
			Scale scale = zg1.GraphPane.XAxis.Scale;
			Scale scale2 = zg1.GraphPane.YAxis.Scale;
			Scale scale3 = zg1.GraphPane.Y2Axis.Scale;
			scale.MinAuto = status;
			scale.MaxAuto = status;
			scale.MajorStepAuto = status;
			scale.MinorStepAuto = status;
			scale2.MinAuto = status;
			scale2.MaxAuto = status;
			scale2.MajorStepAuto = status;
			scale2.MinorStepAuto = status;
			scale3.MinAuto = status;
			scale3.MaxAuto = status;
			scale3.MajorStepAuto = status;
			scale3.MinorStepAuto = status;
		}

		public void CallYAxisScale(bool bAutoScale, double Min, double Max)
		{
			if (bAutoScale)
			{
				zg1.GraphPane.YAxis.Scale.MinAuto = true;
				zg1.GraphPane.YAxis.Scale.MaxAuto = true;
				zg1.GraphPane.YAxis.Scale.MajorStepAuto = true;
				zg1.GraphPane.YAxis.Scale.MinorStepAuto = true;
				return;
			}
			zg1.GraphPane.YAxis.Scale.MaxAuto = false;
			zg1.GraphPane.YAxis.Scale.MinAuto = false;
			zg1.GraphPane.YAxis.Scale.MajorStepAuto = false;
			zg1.GraphPane.YAxis.Scale.MinorStepAuto = false;
			zg1.GraphPane.YAxis.Scale.MagAuto = false;
			zg1.GraphPane.YAxis.Scale.Min = Min;
			zg1.GraphPane.YAxis.Scale.Max = Max;
			double num = CalculateStepSize(Min, Max);
			zg1.GraphPane.YAxis.Scale.MajorStep = num;
			zg1.GraphPane.YAxis.Scale.MinorStep = num / 5.0;
		}

		public void CallY2AxisScale(bool bAutoScale, double Min, double Max)
		{
			if (bAutoScale)
			{
				zg1.GraphPane.Y2Axis.Scale.MinAuto = true;
				zg1.GraphPane.Y2Axis.Scale.MaxAuto = true;
				zg1.GraphPane.Y2Axis.Scale.MajorStepAuto = true;
				zg1.GraphPane.Y2Axis.Scale.MinorStepAuto = true;
			}
			else
			{
				zg1.GraphPane.Y2Axis.Scale.MaxAuto = false;
				zg1.GraphPane.Y2Axis.Scale.MinAuto = false;
				zg1.GraphPane.Y2Axis.Scale.MajorStepAuto = false;
				zg1.GraphPane.Y2Axis.Scale.MinorStepAuto = false;
				zg1.GraphPane.Y2Axis.Scale.MagAuto = false;
				zg1.GraphPane.Y2Axis.Scale.Min = Min;
				zg1.GraphPane.Y2Axis.Scale.Max = Max;
			}
		}

		public void CallGetAxisMinMax(string Axis, out double Min, out double Max)
		{
			Min = 0.0;
			Max = 0.0;
			if (Axis == "XAxis")
			{
				Min = zg1.GraphPane.XAxis.Scale.Min;
				Max = zg1.GraphPane.XAxis.Scale.Max;
			}
			if (Axis == "YAxis")
			{
				Min = zg1.GraphPane.YAxis.Scale.Min;
				Max = zg1.GraphPane.YAxis.Scale.Max;
			}
			if (Axis == "Y2Axis")
			{
				Min = zg1.GraphPane.Y2Axis.Scale.Min;
				Max = zg1.GraphPane.Y2Axis.Scale.Max;
			}
		}

		public void CallY2AxisTitle(string title)
		{
			zg1.GraphPane.Y2Axis.Title.Text = title;
		}

		public void CallAxisChange()
		{
			zg1.AxisChange();
		}

		public void CallInvalidate()
		{
			zg1.Invalidate();
		}

		public void CallResetXScale()
		{
			zg1.GraphPane.XAxis.Scale.Max = 1.2;
		}

		public void CallRemoveAllCurve()
		{
			foreach (LineItem curve in zg1.GraphPane.CurveList)
			{
				zg1.GraphPane.CurveList.Remove(curve);
			}
			zg1.AxisChange();
			zg1.Invalidate();
		}

		public void CallRealTimeSet(int RolPoint, string myLineText, Color myLineColor)
		{
			RollingPointPairList points = new RollingPointPairList(RolPoint, true);
			LineItem lineItem = zg1.GraphPane.AddCurve(myLineText, points, myLineColor, SymbolType.None);
			lineItem.Line.Width = 1f;
			lineItem.Line.IsSmooth = true;
			lineItem.Line.SmoothTension = 0.6f;
			lineItem.Symbol.Fill = new Fill(Color.Transparent);
			lineItem.IsOverrideOrdinal = true;
			zg1.IsShowPointValues = true;
			zg1.AxisChange();
		}

		public void CallRealTimeListSet(int index, int Point)
		{
			if (zg1.GraphPane.CurveList.Count > index)
			{
				RollingPointPairList rollingPointPairList = new RollingPointPairList(Point, true);
				CurveItem curveItem = zg1.GraphPane.CurveList[index];
				rollingPointPairList.Add(curveItem.Points);
				curveItem.Points = rollingPointPairList;
			}
		}

		public void CallGetCurveMinMax(int index, out double Min, out double Max)
		{
			Min = 0.0;
			Max = 0.0;
			if (zg1.GraphPane.CurveList.Count > index)
			{
				CurveItem curveItem = zg1.GraphPane.CurveList[index];
				for (int i = 0; i < curveItem.NPts; i++)
				{
					Min = Math.Min(Min, curveItem.Points[i].Y);
					Max = Math.Max(Max, curveItem.Points[i].Y);
				}
			}
			else
			{
				Min = -100.0;
				Max = 100.0;
			}
		}

		public void CallRealTimeRemove(string strName)
		{
			foreach (LineItem curve in zg1.GraphPane.CurveList)
			{
				if (curve.Label.Text == strName)
				{
					zg1.GraphPane.CurveList.Remove(curve);
					zg1.AxisChange();
					zg1.Invalidate();
					break;
				}
			}
		}

		public void CallRealTimeUpdate(int index, double xTime, long tickStart, long dwStart, double[] strStream1)
		{
			if (zg1.GraphPane.CurveList.Count <= 0 || strStream1.Length == 0)
			{
				return;
			}
			LineItem lineItem = zg1.GraphPane.CurveList[index] as LineItem;
			if (lineItem == null)
			{
				return;
			}
			IPointListEdit pointListEdit = lineItem.Points as IPointListEdit;
			if (pointListEdit != null)
			{
				double num = (double)(Environment.TickCount - tickStart) / xTime;
				Scale scale = zg1.GraphPane.XAxis.Scale;
				if (num > scale.Max - scale.MajorStep)
				{
					scale.Max = num + scale.MajorStep;
					scale.Min = scale.Max - 30.0;
				}
				if (strStream1.Length > 2)
				{
					pointListEdit.Add(num, strStream1[0]);
					pointListEdit.Add(num, strStream1[strStream1.Length / 2]);
				}
				else
				{
					pointListEdit.Add(xTime, strStream1[0]);
				}
				zg1.GraphPane.YAxis.Scale.MinAuto = true;
				zg1.GraphPane.YAxis.Scale.MaxAuto = true;
				zg1.GraphPane.YAxis.Scale.MinorStepAuto = true;
				zg1.GraphPane.YAxis.Scale.MajorStepAuto = true;
				long num2 = Environment.TickCount - dwStart;
				zg1.GraphPane.XAxis.Title.Text = string.Format(bufferSizeAxisTextFormatText, strStream1.Length, Convert.ToString(num2, enUSCulture));
				dwStart = Environment.TickCount;
				zg1.AxisChange();
				zg1.Invalidate();
			}
		}

		public void CallRealTimeUpdateQueue(int index, double xTime, long tickStart, long dwStart, Queue strStream1)
		{
			if (zg1.GraphPane.CurveList.Count <= 0)
			{
				return;
			}
			LineItem lineItem = zg1.GraphPane.CurveList[index] as LineItem;
			if (lineItem == null)
			{
				return;
			}
			RollingPointPairList rollingPointPairList = lineItem.Points as RollingPointPairList;
			if (rollingPointPairList != null)
			{
				for (int i = 0; i < rollingPointPairList.Count; i++)
				{
					rollingPointPairList[i].X = rollingPointPairList[i].X + 1.0;
				}
				rollingPointPairList.Add(xTime, Convert.ToDouble(strStream1.Peek().ToString(), enUSCulture));
				strStream1.Dequeue();
				long num = Environment.TickCount - dwStart;
				zg1.GraphPane.XAxis.Title.Text = string.Format(queueSizeAxisTextFormatText, strStream1.Count, Convert.ToString(num, enUSCulture), rollingPointPairList.Count, xTime);
				dwStart = Environment.TickCount;
				zg1.AxisChange();
				zg1.Invalidate();
			}
		}

		public void AddHorizontalToChart(string Names, int xRow, double[] DataArray, out double[] outHorizon)
		{
			outHorizon = new double[xRow];
			double val = Convert.ToDouble(DataArray[0], enUSCulture);
			double val2 = Convert.ToDouble(DataArray[0], enUSCulture);
			for (int i = 0; i < xRow; i++)
			{
				outHorizon[i] = Convert.ToDouble(DataArray[i].ToString());
				val = Math.Max(val, Convert.ToDouble(DataArray[i].ToString(), enUSCulture));
				val2 = Math.Min(val2, Convert.ToDouble(DataArray[i].ToString(), enUSCulture));
			}
			SetXAxisTitle(Names);
			zg1.AxisChange();
		}

		public void AddTimebaseSecondHorizontalToChart(string Names, int xRow, double[] DataArray, out double[] outTimebase, double ServoTime)
		{
			SampleTime = (Convert.ToDouble(DataArray[1].ToString(), enUSCulture) - Convert.ToDouble(DataArray[0].ToString(), enUSCulture)) * ServoTime;
			outTimebase = new double[xRow];
			for (int i = 0; i < xRow; i++)
			{
				outTimebase[i] = (Convert.ToDouble(DataArray[i].ToString(), enUSCulture) - Convert.ToDouble(DataArray[0].ToString(), enUSCulture)) * 0.001 * ServoTime;
			}
			SetXAxisTitle(Names);
			myPane.XAxis.MajorGrid.IsVisible = true;
			zg1.AxisChange();
		}

		public void AddTimebaseHorizontalToChart(string Names, int xRow, double[] DataArray, out double[] outTimebase, double ServoTime)
		{
			SampleTime = ServoTime;
			outTimebase = new double[xRow];
			for (int i = 0; i < xRow; i++)
			{
				outTimebase[i] = (Convert.ToDouble(DataArray[i].ToString(), enUSCulture) - Convert.ToDouble(DataArray[0].ToString(), enUSCulture)) * ServoTime;
			}
			SetXAxisTitle(Names);
			myPane.XAxis.MajorGrid.IsVisible = true;
			zg1.AxisChange();
		}

		public void AddFreqbaseHorizontalToChart(string Names, int xRow, double[] DataArray, out double[] outTimebase, double SampleTime)
		{
			outTimebase = new double[xRow];
			SetXAxisTitle(Names);
			myPane.XAxis.MajorGrid.IsVisible = true;
			zg1.AxisChange();
		}

		private void SetXAxisTitle(string titleText)
		{
			if (!(titleText == "Time(sec)"))
			{
				if (titleText == "Time(ms)")
				{
					titleText = timeMillisecondsText;
				}
			}
			else
			{
				titleText = timeSecondsText;
			}
			myPane.XAxis.Title.Text = titleText;
		}

		public void AddSeriesToChart(string LegendName, string TitleNames, string XAxis, string YAxis, int xRow, double nMin, double nMax, double[] inHorizon, double[] inArray, Color SerColor)
		{
			PointPairList pointPairList = new PointPairList();
			for (int i = 0; i < xRow; i++)
			{
				pointPairList.Add(inHorizon[i], inArray[i]);
			}
			if (XAxis == "XAxis" && YAxis == "YAxis")
			{
				myPane.YAxis.Scale.FontSpec.FontColor = Color.White;
				myPane.YAxis.Title.Text = TitleNames;
				myPane.YAxis.Type = ZedGraph.AxisType.Linear;
				LineItem lineItem = myPane.AddCurve(LegendName, pointPairList, SerColor, SymbolType.None);
				lineItem.Line.Width = 1f;
				lineItem.Symbol.Fill = new Fill(Color.Transparent);
			}
			else if (XAxis == "XAxis" && YAxis == "Y2Axis")
			{
				myPane.Y2Axis.IsVisible = true;
				myPane.Y2Axis.Scale.FontSpec.FontColor = Color.White;
				myPane.Y2Axis.Title.Text = TitleNames;
				myPane.Y2Axis.MajorTic.IsOpposite = false;
				myPane.Y2Axis.MinorTic.IsOpposite = false;
				myPane.Y2Axis.MajorGrid.IsZeroLine = false;
				myPane.Y2Axis.Scale.Align = AlignP.Inside;
				LineItem lineItem2 = myPane.AddCurve(LegendName, pointPairList, SerColor, SymbolType.None);
				lineItem2.Line.Width = 1f;
				lineItem2.Symbol.Fill = new Fill(Color.Transparent);
				lineItem2.IsY2Axis = true;
			}
			else if (XAxis == "X2Axis" && YAxis == "YAxis")
			{
				myPane.YAxis.Scale.FontSpec.FontColor = Color.White;
				myPane.YAxis.Scale.Align = AlignP.Inside;
				myPane.YAxis.Title.Text = TitleNames;
				LineItem lineItem3 = myPane.AddCurve(LegendName, pointPairList, SerColor, SymbolType.None);
				lineItem3.Line.Width = 1f;
				lineItem3.Symbol.Fill = new Fill(Color.Transparent);
				lineItem3.IsX2Axis = true;
			}
			else if (XAxis == "X2Axis" && YAxis == "Y2Axis")
			{
				myPane.Y2Axis.IsVisible = true;
				myPane.Y2Axis.Scale.FontSpec.FontColor = Color.White;
				myPane.Y2Axis.Scale.Align = AlignP.Inside;
				myPane.Y2Axis.Title.Text = TitleNames;
				LineItem lineItem4 = myPane.AddCurve(LegendName, pointPairList, SerColor, SymbolType.None);
				lineItem4.Line.Width = 1f;
				lineItem4.Symbol.Fill = new Fill(Color.Transparent);
				lineItem4.IsY2Axis = true;
				lineItem4.IsX2Axis = true;
			}
			zg1.AxisChange();
		}

		public void FindMinMax(out double nMin, out double nMax, double[] InArray, int NumArray)
		{
			nMax = Convert.ToDouble(InArray[0], enUSCulture);
			nMin = Convert.ToDouble(InArray[0], enUSCulture);
			for (int i = 0; i < NumArray; i++)
			{
				nMax = Math.Max(nMax, InArray[i]);
				nMin = Math.Min(nMin, InArray[i]);
			}
		}

		private double CalculateStepSize(double max, double min)
		{
			double num = 6.0;
			double value = ((!(max - min > 5.0)) ? (max - min) : (Math.Ceiling(max) - Math.Floor(min)));
			value = Math.Abs(value);
			double num2 = value / num;
			double num3 = Math.Floor(Math.Log10(num2));
			double num4 = Math.Pow(10.0, num3);
			double num5 = (int)(num2 / num4 + 0.5);
			if (num5 > 5.0)
			{
				num5 = 10.0;
			}
			else if (num5 > 2.0)
			{
				num5 = 5.0;
			}
			else if (num5 > 1.0)
			{
				num5 = 2.0;
			}
			return num5 * num4;
		}

		private void PPChartControl_Resize(object sender, EventArgs e)
		{
			SetSize();
		}

		private void PageSetupItem_Click(object sender, EventArgs e)
		{
			zg1.DoPageSetup();
		}

		private void PrintPreviewItem_Click(object sender, EventArgs e)
		{
			zg1.DoPrintPreview();
		}

		private void printItem_Click(object sender, EventArgs e)
		{
			zg1.IsPrintFillPage = true;
			zg1.IsPrintKeepAspectRatio = true;
			zg1.IsPrintScaleAll = true;
			SetColorForPrint(true);
			zg1.Refresh();
			zg1.DoPrint();
			if (GetPaneSavedBackgroundColor() != Color.White)
			{
				SetColorForPrint(false);
			}
			zg1.Refresh();
		}

		private Color GetPaneSavedBackgroundColor()
		{
			INI_ReadWrite iNI_ReadWrite = new INI_ReadWrite(INIFileName);
			return (Color)new ColorConverter().ConvertFromString(iNI_ReadWrite.IniReadValue("Chart Settings", "Chart Background"));
		}

		private void SetColorForPrint(bool flag)
		{
			if (flag)
			{
				SetAllChartColor(printBackgroundcolor, Color.Black);
			}
			else
			{
				SetAllChartColor(chartBackgroundcolor, Color.White);
			}
		}

		private void pageSetupToolStripMenuItem_Click(object sender, EventArgs e)
		{
			PageSetupItem_Click(sender, e);
		}

		private void printPreviewToolStripMenuItem_Click(object sender, EventArgs e)
		{
			PrintPreviewItem_Click(sender, e);
		}

		private void printToolStripMenuItem_Click(object sender, EventArgs e)
		{
			printItem_Click(sender, e);
		}

		private void MyZoomEvent(ZedGraphControl control, ZoomState oldState, ZoomState newState)
		{
			bool isZoomed = control.GraphPane.IsZoomed;
		}

		public void doFFTNoDialogs(bool filtersig, bool sigdb)
		{
			skipDiag = true;
			filtersignal = filtersig;
			signaldb = sigdb;
			doFFTofsignals();
			skipDiag = false;
			if (this.ChartFFTComplete != null)
			{
				this.ChartFFTComplete(this, new EventArgs());
			}
		}

		private void doFFTofsignals()
		{
			CurveList curveList = zg1.GraphPane.CurveList;
			if (toolStripMenuItem_FFT.Checked)
			{
				if (!istuneplot)
				{
					preFFT = zg1.GraphPane.CurveList.Clone();
				}
				int num = 0;
				double[][] array = null;
				double[][] array2 = null;
				array = new double[curveList.Count][];
				array2 = new double[curveList.Count][];
				double[][] array3 = null;
				double[][] array4 = null;
				string[] array5 = null;
				Color[] array6 = null;
				array3 = new double[curveList.Count][];
				array4 = new double[curveList.Count][];
				array5 = new string[curveList.Count];
				array6 = new Color[curveList.Count];
				long numTemp = 0L;
				bool filtered = false;
				bool flag = false;
				if (!skipDiag)
				{
					signaldb = false;
					filtersignal = false;
					if (MessageBox.Show(wouldYouLikeToFilterTheSignalsText, fftInformationText, MessageBoxButtons.YesNo) == DialogResult.Yes)
					{
						filtered = true;
						filtersignal = true;
					}
					if (MessageBox.Show(wouldYouLikeTheSignalsInDecibelsText, fftInformationText, MessageBoxButtons.YesNo) == DialogResult.Yes)
					{
						flag = true;
						signaldb = true;
					}
				}
				else
				{
					filtered = filtersignal;
					flag = signaldb;
				}
				foreach (CurveItem item in curveList)
				{
					IPointList points = item.Points;
					array[num] = new double[points.Count * 4];
					array2[num] = new double[points.Count * 4];
					for (int i = 0; i < points.Count; i++)
					{
						array[num][i] = points[i].X;
						array2[num][i] = points[i].Y;
					}
					if (ProcessFFT(points.Count, out numTemp, ref array2[num], item.Label.Text, flag, filtered) == 0L)
					{
						return;
					}
					for (int j = 0; j < numTemp; j++)
					{
						array[num][j] = (double)j * (1000.0 / SampleTime) / (double)(2 * numTemp);
					}
					array3[num] = new double[numTemp];
					array4[num] = new double[numTemp];
					for (int k = 0; k < numTemp; k++)
					{
						array3[num][k] = array[num][k];
						array4[num][k] = array2[num][k];
					}
					array5[num] = item.Label.Text;
					array6[num] = item.Color;
					num++;
				}
				zg1.GraphPane.CurveList.Clear();
				double[] array7 = null;
				double[] array8 = null;
				array7 = new double[numTemp];
				array8 = new double[numTemp];
				for (int l = 0; l < array5.Length; l++)
				{
					string label = array5[l];
					for (int m = 0; m < array3[l].Length; m++)
					{
						array7[m] = array3[l][m];
						array8[m] = array4[l][m];
					}
					PointPairList pointPairList = new PointPairList();
					pointPairList.Add(array7, array8);
					zg1.GraphPane.AddCurve(label, pointPairList, array6[l], SymbolType.None);
				}
				string text = zg1.GraphPane.XAxis.Title.Text;
				preFFTXTitle = zg1.GraphPane.XAxis.Title.Text;
				if (text.Contains(timeMillisecondsText))
				{
					text = text.Replace(timeMillisecondsText, $"{frequencyText} (Hz)");
					zg1.GraphPane.XAxis.Title.Text = text;
				}
				if (text.Contains(timeSecondsText))
				{
					text = text.Replace(timeSecondsText, $"{frequencyText} (Hz)");
					zg1.GraphPane.XAxis.Title.Text = text;
				}
				if (flag)
				{
					string text2 = zg1.GraphPane.YAxis.Title.Text;
					preFFTYTitle = zg1.GraphPane.YAxis.Title.Text;
					if (text2.Contains("/(ms)^2"))
					{
						text2 = text2.Replace("/(ms)^2", "");
					}
					if (text2.Contains("/(ms)"))
					{
						text2 = text2.Replace("/(ms)", "");
					}
					if (text2.Contains("m unit"))
					{
						text2 = text2.Replace("m unit", "dB");
					}
					else if (!string.IsNullOrEmpty(text2) && !text2.Contains("dB"))
					{
						text2 += "(dB)";
					}
					zg1.GraphPane.YAxis.Title.Text = text2;
					string text3 = zg1.GraphPane.Y2Axis.Title.Text;
					preFFTY2Title = zg1.GraphPane.Y2Axis.Title.Text;
					if (text3.Contains("/(ms)^2"))
					{
						text3 = text3.Replace("/(ms)^2", "");
					}
					if (text3.Contains("/(ms)"))
					{
						text3 = text3.Replace("/(ms)", "");
					}
					if (text3.Contains("m unit"))
					{
						text3 = text3.Replace("m unit", "dB");
					}
					else if (!string.IsNullOrEmpty(text3) && !text3.Contains("dB"))
					{
						text3 += "(dB)";
					}
					zg1.GraphPane.Y2Axis.Title.Text = text3;
				}
				else
				{
					preFFTYTitle = string.Empty;
					preFFTY2Title = string.Empty;
				}
				SetAutoScale(true);
				zg1.AxisChange();
				zg1.Invalidate();
			}
			else if (!istuneplot)
			{
				zg1.GraphPane.CurveList = preFFT;
				if (preFFTY2Title != null && preFFTY2Title != string.Empty)
				{
					zg1.GraphPane.Y2Axis.Title.Text = preFFTY2Title;
				}
				if (preFFTYTitle != null && preFFTYTitle != string.Empty)
				{
					zg1.GraphPane.YAxis.Title.Text = preFFTYTitle;
				}
				if (preFFTXTitle != null && preFFTXTitle != string.Empty)
				{
					zg1.GraphPane.XAxis.Title.Text = preFFTXTitle;
				}
				SetSize();
				Cursor = Cursors.Default;
				SetAutoScale(true);
				zg1.AxisChange();
				zg1.Invalidate();
			}
			else
			{
				zg1.GraphPane.CurveList.Clear();
				if (isgantry)
				{
					LoadTuneGantryPlot(istuneplot, issinesweep, islogaritmic, start_freq, end_freq, isopenloop, commandedpos, actualpos, servocommand, actualpos_gantry, servocommand_gantry, gathertime, stats, horizantalaxisitem, sleftaxisitem, srightaxisitem, title, homeposition, homeposition_gantry, cmdposinitial, masterposition_gantry);
				}
				else if (iscurrentstepplot)
				{
					LoadCurrentTunePlot(istuneplot, iscurrentstepplot, idmeasured, timeinphasecycles, tscurrent, stats, xcol, xrow, title);
				}
				else
				{
					LoadTunePlot(istuneplot, issinesweep, islogaritmic, start_freq, end_freq, isopenloop, commandedpos, actualpos, servocommand, gathertime, stats, horizantalaxisitem, sleftaxisitem, srightaxisitem, title, homeposition, cmdposinitial);
				}
			}
		}

		private void SoapSerialize(ZedGraphControl z1, string fileName)
		{
			try
			{
				if (z1 != null && !string.IsNullOrEmpty(fileName))
				{
					SoapFormatter soapFormatter = new SoapFormatter();
					Stream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None);
					soapFormatter.Serialize(stream, z1.GraphPane);
					stream.Close();
				}
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message);
			}
		}

		private void SoapDeSerialize(ZedGraphControl z1, string fileName)
		{
			Stream stream = null;
			try
			{
				if (z1 != null && !string.IsNullOrEmpty(fileName))
				{
					SoapFormatter soapFormatter = new SoapFormatter();
					stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
					soapFormatter.Binder = new Version1ToVersion2DeserializationBinder();
					GraphPane graphPane = null;
					try
					{
						graphPane = (GraphPane)soapFormatter.Deserialize(stream);
						return;
					}
					finally
					{
						stream.Close();
						z1.GraphPane = graphPane;
						myPane = graphPane;
						z1.Refresh();
						z1.Size = z1.Size;
					}
				}
			}
			catch (Exception)
			{
				MessageBox.Show(this, string.Format(invalidFileFormatTextFormat, fileName));
			}
		}

		private void OpenProperty(object sender, EventArgs args)
		{
			FormProperty obj = new FormProperty(istuneplot)
			{
				StartPosition = FormStartPosition.Manual
			};
			Point point = new Point
			{
				X = base.Parent.Location.X,
				Y = base.Parent.Location.Y
			};
			obj.Location = new Point(point.X, point.Y);
			obj.MinimizeBox = false;
			obj.MaximizeBox = false;
			obj.Tag = this;
			obj.BringToFront();
			obj.TopMost = true;
			DialogResult dialogResult = DialogResult.None;
			switch (obj.ShowDialog(IDEGlobals.CreateWin32WindowWrapperFromPtr(base.Handle)))
			{
			case DialogResult.OK:
				if (SetChartType != 0)
				{
					int num = 1;
					break;
				}
				SetChartDetails();
				CanSaveData = CanSave.YES;
				break;
			case DialogResult.Cancel:
				CanSaveData = CanSave.NO;
				break;
			}
		}

		private void toolStripMenuItem_FFT_Click(object sender, EventArgs e)
		{
			doFFTofsignals();
		}

		public void openPlotDataToolStripMenuItem_Click(object sender, EventArgs e)
		{
			OpenFileDialog openFileDialog = new OpenFileDialog();
			openFileDialog.Filter = $"{pppFilesText} (*.ppp)|*.ppp|{allFilesText} (*.*)|*.*";
			openFileDialog.FilterIndex = 1;
			openFileDialog.RestoreDirectory = true;
			if (openFileDialog.ShowDialog(IDEGlobals.CreateWin32WindowWrapperFromPtr(base.Handle)) == DialogResult.OK)
			{
				Cursor = Cursors.WaitCursor;
				SoapDeSerialize(zg1, openFileDialog.FileName);
				if (this.ChartLoaded != null)
				{
					this.ChartLoaded(this, openFileDialog.FileName);
				}
				SetSize();
				Cursor = Cursors.Default;
				Form form = base.Parent as Form;
				if (form != null)
				{
					form.Text = openFileDialog.FileName;
				}
			}
			modifyPlotItemsToolStripMenuItem.Enabled = false;
			istuneplot = false;
		}

		private void savePlotDataToolStripMenuItem_Click(object sender, EventArgs e)
		{
			SaveFileDialog saveFileDialog = new SaveFileDialog();
			saveFileDialog.Filter = $"{pppFilesText} (*.ppp)|*.ppp|{allFilesText} (*.*)|*.*";
			saveFileDialog.FilterIndex = 1;
			saveFileDialog.RestoreDirectory = true;
			if (saveFileDialog.ShowDialog(IDEGlobals.CreateWin32WindowWrapperFromPtr(base.Handle)) == DialogResult.OK && saveFileDialog.FileName != null)
			{
				SoapSerialize(zg1, saveFileDialog.FileName);
				if (this.ChartSaved != null)
				{
					this.ChartSaved(this, saveFileDialog.FileName);
				}
			}
		}

		private void modifyPlotItemsToolStripMenuItem_Click(object sender, EventArgs e)
		{
			ChangePlotItems changePlotItems = new ChangePlotItems(isgantry, issinesweep, isfreqbasedplot, isopenloop, normalizedplot, rightaxisitem, leftaxisitem);
			changePlotItems.ShowDialog(IDEGlobals.CreateWin32WindowWrapperFromPtr(base.Handle));
			if (changePlotItems.DialogResult == DialogResult.OK)
			{
				isfreqbasedplot = changePlotItems.changedisfreqbased;
				normalizedplot = changePlotItems.changednormalized;
				leftaxisitem = changePlotItems.changedleftaxisitems;
				rightaxisitem = changePlotItems.changedrightaxisitems;
				ChangeTunePlot(isfreqbasedplot, normalizedplot, leftaxisitem, rightaxisitem);
			}
		}

		private void smoothToolStripMenuItem_Click(object sender, EventArgs e)
		{
			if (!smoothToolStripMenuItem.Checked)
			{
				MovingAverageFilter movingAverageFilter = new MovingAverageFilter(movingaveragefiltered, mafilterorder);
				movingAverageFilter.ShowDialog(IDEGlobals.CreateWin32WindowWrapperFromPtr(base.Handle));
				if (movingAverageFilter.DialogResult == DialogResult.OK)
				{
					Cursor = Cursors.WaitCursor;
					mafilterorder = movingAverageFilter.filterorder;
					movingaveragefiltered = movingAverageFilter.filtersignals;
					if (movingaveragefiltered)
					{
						smoothToolStripMenuItem.Checked = true;
					}
					CurveList curveList = zg1.GraphPane.CurveList;
					SoapSerialize(zg1, DefaultPath + "\\GatherMAF.txt");
					int num = 0;
					double[][] array = null;
					double[][] array2 = null;
					double[][] array3 = null;
					array = new double[curveList.Count][];
					array2 = new double[curveList.Count][];
					array3 = new double[curveList.Count][];
					string[] array4 = null;
					Color[] array5 = null;
					array4 = new string[curveList.Count];
					array5 = new Color[curveList.Count];
					double[] OutData = null;
					int num2 = 0;
					foreach (CurveItem item in curveList)
					{
						IPointList points = item.Points;
						num2 = points.Count;
						array[num] = new double[points.Count];
						array2[num] = new double[points.Count];
						for (int i = 0; i < points.Count; i++)
						{
							array[num][i] = points[i].X;
							array2[num][i] = points[i].Y;
						}
						filter_MovingAverage(array2[num], out OutData, points.Count, mafilterorder);
						array3[num] = new double[points.Count];
						for (int j = 0; j < points.Count; j++)
						{
							array3[num][j] = OutData[j];
						}
						array4[num] = item.Label.Text;
						array5[num] = item.Color;
						num++;
					}
					zg1.GraphPane.CurveList.Clear();
					double[] array6 = null;
					double[] array7 = null;
					array6 = new double[num2];
					array7 = new double[num2];
					for (int k = 0; k < array4.Length; k++)
					{
						string label = array4[k];
						for (int l = 0; l < array7.Length; l++)
						{
							array6[l] = array[k][l];
							array7[l] = array3[k][l];
						}
						PointPairList pointPairList = new PointPairList();
						pointPairList.Add(array6, array7);
						zg1.GraphPane.AddCurve(label, pointPairList, array5[k], SymbolType.None);
					}
					zg1.AxisChange();
					zg1.Invalidate();
					Cursor = Cursors.Default;
				}
				else
				{
					smoothToolStripMenuItem.Checked = false;
				}
			}
			else
			{
				SoapDeSerialize(zg1, DefaultPath + "\\GatherMAF.txt");
				SetSize();
				Cursor = Cursors.Default;
				zg1.AxisChange();
				zg1.Invalidate();
				smoothToolStripMenuItem.Checked = false;
			}
		}

		private void saveRawDataToolStripMenuItem_Click(object sender, EventArgs e)
		{
			SaveFileDialog saveFileDialog = new SaveFileDialog();
			saveFileDialog.Filter = $"{textFilesText} (*.txt)|*.txt|{allFilesText} (*.*)|*.*";
			saveFileDialog.FilterIndex = 1;
			saveFileDialog.RestoreDirectory = true;
			if (saveFileDialog.ShowDialog(IDEGlobals.CreateWin32WindowWrapperFromPtr(base.Handle)) != DialogResult.OK || saveFileDialog.FileName == null)
			{
				return;
			}
			try
			{
				TextWriter textWriter = File.CreateText(saveFileDialog.FileName);
				CurveList curveList = zg1.GraphPane.CurveList;
				textWriter.Write(zg1.GraphPane.XAxis.Title.Text.ToString());
				int num = 0;
				double[][] array = null;
				double[][] array2 = null;
				string[] array3 = null;
				array = new double[curveList.Count][];
				array2 = new double[curveList.Count][];
				int num2 = 0;
				array3 = new string[curveList.Count];
				foreach (CurveItem item in curveList)
				{
					array3[num] = item.Label.Text;
					textWriter.Write("  " + array3[num].ToString());
				}
				foreach (CurveItem item2 in curveList)
				{
					IPointList points = item2.Points;
					num2 = points.Count;
					array[num] = new double[points.Count];
					array2[num] = new double[points.Count];
					for (int i = 0; i < points.Count; i++)
					{
						array[num][i] = points[i].X;
						array2[num][i] = points[i].Y;
					}
					num++;
				}
				for (int j = 0; j < num2; j++)
				{
					textWriter.Write("\r\n" + array[0][j].ToString("F17"));
					for (int k = 0; k < num; k++)
					{
						textWriter.Write(" " + array2[k][j].ToString("F17"));
					}
				}
				textWriter.Close();
			}
			catch (Exception ex)
			{
				throw new Exception(ex.Message);
			}
		}

		private void PPChartControl_Load(object sender, EventArgs e)
		{
			string iNIFile = new FormProperty(istuneplot).GetINIFile();
			SetChartTypeValue();
			switch (SetChartType)
			{
			case ChartType.Tune:
				SetChartColor(chartBackgroundcolor, Color.White);
				break;
			case ChartType.Plot:
				if (!RestoreGraphPhane(iNIFile))
				{
					SetChartColor(chartBackgroundcolor, Color.White);
				}
				break;
			}
		}

		private void SetChartTypeValue()
		{
			if (istuneplot)
			{
				SetChartType = ChartType.Tune;
			}
			else
			{
				SetChartType = ChartType.Plot;
			}
		}

		public void Do_FFT(long NN, ref double[] Odata, long numSamp)
		{
			double num = 0.0;
			double num2 = 0.0;
			double num3 = 0.0;
			double num4 = 0.0;
			double num5 = 0.0;
			double num6 = 0.0;
			double num7 = 0.0;
			double num8 = 0.0;
			long num9 = 0L;
			long num10 = 0L;
			long num11 = 0L;
			long num12 = 0L;
			long num13 = 0L;
			double[] array = null;
			num11 = 2 * NN;
			array = new double[num11 + 1];
			for (int i = 0; i < NN; i++)
			{
				array[i + 1] = Odata[i];
			}
			num9 = 1L;
			for (int j = 1; j < num11; j += 2)
			{
				if (num9 > j)
				{
					num7 = array[num9];
					num8 = array[num9 + 1];
					array[num9] = array[j];
					array[num9 + 1] = array[j + 1];
					array[j] = num7;
					array[j + 1] = num8;
				}
				num10 = num11 / 2;
				while (num10 >= 2 && num9 > num10)
				{
					num9 -= num10;
					num10 /= 2;
				}
				num9 += num10;
			}
			num13 = 2L;
			while (num11 > num13)
			{
				num12 = 2 * num13;
				num6 = 6.283185307 / (double)num13;
				num5 = Math.Sin(0.5 * num6);
				num3 = -2.0 * num5 * num5;
				num4 = Math.Sin(num6);
				num = 1.0;
				num2 = 0.0;
				for (int k = 1; k < num13; k += 2)
				{
					for (int l = k; l < num11 + 1; l += (int)num12)
					{
						num9 = l + num13;
						num7 = num * array[num9] - num2 * array[num9 + 1];
						num8 = num * array[num9 + 1] + num2 * array[num9];
						array[num9] = array[l] - num7;
						array[num9 + 1] = array[l + 1] - num8;
						array[l] += num7;
						array[l + 1] += num8;
					}
					num5 = num;
					num = num * num3 - num2 * num4 + num;
					num2 = num2 * num3 + num5 * num4 + num2;
				}
				num13 = num12;
			}
			for (int m = 0; m < NN; m++)
			{
				Odata[m] = array[m + 1] / (double)numSamp;
			}
		}

		public long ProcessFFT(long numSamp, out long numTemp, ref double[] FFTdata, string PPLLeg, bool logscale, bool filtered)
		{
			RemoveDCBias(numSamp, ref FFTdata);
			long num = ResizeHanningAndPadZero(numSamp, out numTemp, ref FFTdata, filtered);
			if (num <= 0)
			{
				return 0L;
			}
			long nN = num * 2;
			Do_FFT(nN, ref FFTdata, numSamp);
			Magnitude(num, ref FFTdata, PPLLeg, logscale);
			return num;
		}

		public void RemoveDCBias(long nsamp, ref double[] data)
		{
			double num = 0.0;
			for (long num2 = 0L; num2 < nsamp; num2++)
			{
				num += data[num2];
			}
			double num3 = num / (double)nsamp;
			for (int i = 0; i < nsamp; i++)
			{
				data[i] -= num3;
			}
		}

		public long ResizeHanningAndPadZero(long NS, out long NT, ref double[] data, bool filtered)
		{
			try
			{
				double[] array = null;
				NT = 0L;
				if (NS <= 32)
				{
					NT = 0L;
					MessageBox.Show(fftErrorText, plotErrorText, MessageBoxButtons.OK, MessageBoxIcon.Hand);
					return 0L;
				}
				for (int i = 5; i < 32; i++)
				{
					if (Math.Pow(2.0, i) < (double)NS && Math.Pow(2.0, i + 1) >= (double)NS)
					{
						NT = (long)Math.Pow(2.0, i + 1);
					}
				}
				if (filtered)
				{
					for (int j = 0; j < NS; j++)
					{
						data[j] *= 0.54 - 0.46 * Math.Cos(Math.PI * 2.0 * (double)j / (double)(NT - 1));
					}
				}
				array = new double[2 * NT + 1];
				for (int k = 0; k < NS; k++)
				{
					array[2 * k] = data[k];
					array[2 * k + 1] = 0.0;
				}
				for (long num = 2 * NS; num < 2 * NT; num++)
				{
					array[num] = 0.0;
				}
				for (int l = 0; l < 2 * NT + 1; l++)
				{
					data[l] = array[l];
				}
				return NT;
			}
			catch
			{
				NT = 0L;
				return 0L;
			}
		}

		public void Magnitude(long NT, ref double[] data, string PPLLeg, bool logscale)
		{
			double[] array = null;
			array = new double[NT];
			for (int i = 0; i < NT; i++)
			{
				array[i] = 2.0 * Math.Sqrt(Math.Pow(data[2 * i], 2.0) + Math.Pow(data[2 * i + 1], 2.0));
			}
			if (logscale)
			{
				for (int j = 0; j < NT; j++)
				{
					array[j] = 20.0 * Math.Log10(array[j]);
				}
			}
			for (int k = 0; k < NT; k++)
			{
				data[k] = array[k];
			}
		}

		public void LoadTunePlot(bool isTuneplot, bool issinesweepplot, bool islogarithmicsweep, double freqstart, double freqend, bool isopenloopplot, double[] CommandedPosition, double[] ActualPosition, double[] ServoCommand, double GatherSamplingTime, string statistics, string HorizantalAxisItem, string LeftAxisItem, string RightAxisItem, string Title, double initial_homeposition, double initial_commandedpos)
		{
			try
			{
				istuneplot = isTuneplot;
				isopenloop = isopenloopplot;
				toolStripMenuItem_Tools.Enabled = true;
				toolStripMenuItem_FFT.Checked = false;
				commandedpos = CommandedPosition;
				actualpos = ActualPosition;
				servocommand = ServoCommand;
				gathertime = GatherSamplingTime;
				SampleTime = gathertime;
				stats = statistics;
				isgantry = false;
				issinesweep = issinesweepplot;
				islogaritmic = islogarithmicsweep;
				start_freq = freqstart;
				end_freq = freqend;
				horizantalaxisitem = HorizantalAxisItem;
				title = Title;
				homeposition = initial_homeposition;
				cmdposinitial = initial_commandedpos;
				movingaveragefiltered = false;
				if (_useAxisItems)
				{
					isfreqbasedplot = false;
					normalizedplot = 2;
					leftaxisitem = new int[6];
					rightaxisitem = new int[6];
					sleftaxisitem = LeftAxisItem;
					srightaxisitem = RightAxisItem;
					if (sleftaxisitem == "Position")
					{
						leftaxisitem[0] = 1;
					}
					else
					{
						leftaxisitem[0] = 0;
					}
					if (sleftaxisitem == "Velocity")
					{
						leftaxisitem[1] = 1;
					}
					else
					{
						leftaxisitem[1] = 0;
					}
					if (sleftaxisitem == "Acceleration")
					{
						leftaxisitem[2] = 1;
					}
					else
					{
						leftaxisitem[2] = 0;
					}
					if (sleftaxisitem == "Servo Command")
					{
						leftaxisitem[3] = 1;
					}
					else
					{
						leftaxisitem[3] = 0;
					}
					if (sleftaxisitem == "Following Error")
					{
						leftaxisitem[4] = 1;
					}
					else
					{
						leftaxisitem[4] = 0;
					}
					leftaxisitem[5] = 0;
					if (srightaxisitem == "Position")
					{
						rightaxisitem[0] = 1;
					}
					else
					{
						rightaxisitem[0] = 0;
					}
					if (srightaxisitem == "Velocity")
					{
						rightaxisitem[1] = 1;
					}
					else
					{
						rightaxisitem[1] = 0;
					}
					if (srightaxisitem == "Acceleration")
					{
						rightaxisitem[2] = 1;
					}
					else
					{
						rightaxisitem[2] = 0;
					}
					if (srightaxisitem == "Servo Command")
					{
						rightaxisitem[3] = 1;
					}
					else
					{
						rightaxisitem[3] = 0;
					}
					if (srightaxisitem == "Following Error")
					{
						rightaxisitem[4] = 1;
					}
					else
					{
						rightaxisitem[4] = 0;
					}
					rightaxisitem[5] = 0;
				}
				InitialChart(title);
				double[] array = new double[commandedpos.Length];
				for (int i = 0; i < commandedpos.Length; i++)
				{
					array[i] = (double)i * gathertime;
				}
				timeinms = array;
				SetXAxisTitle(stats);
				myPane.XAxis.MajorGrid.IsVisible = true;
				int num = commandedpos.Length;
				double nMin = 0.0;
				double nMax = 0.0;
				string text = "";
				string text2 = "";
				Color fontColor = myPane.YAxis.Scale.FontSpec.FontColor;
				Color fontColor2 = myPane.YAxis.Title.FontSpec.FontColor;
				Color fontColor3 = myPane.Y2Axis.Scale.FontSpec.FontColor;
				Color fontColor4 = myPane.Y2Axis.Title.FontSpec.FontColor;
				Color fontColor5 = myPane.XAxis.Scale.FontSpec.FontColor;
				Color fontColor6 = myPane.XAxis.Title.FontSpec.FontColor;
				if (leftaxisitem[0] == 1)
				{
					FindMinMax(out nMin, out nMax, commandedpos, num);
					AddSeriesToChart(commandPositionText, "", "XAxis", "YAxis", num, nMin, nMax, array, commandedpos, commandedposcolor);
					FindMinMax(out nMin, out nMax, actualpos, num);
					AddSeriesToChart(actualPositionText, "", "XAxis", "YAxis", num, nMin, nMax, array, actualpos, actualposcolor);
					text = $"{commandAndActualPositionText} (m unit)";
				}
				double[] OutData;
				double[] OutData2;
				if (leftaxisitem[1] == 1)
				{
					if (!isopenloop)
					{
						FindVelocity(commandedpos, out OutData, num, gathertime);
						FindVelocity(actualpos, out OutData2, num, gathertime);
						FindMinMax(out nMin, out nMax, OutData, num);
						AddSeriesToChart(commandVelocityText, "", "XAxis", "YAxis", num, nMin, nMax, array, OutData, commandedvelcolor);
						FindMinMax(out nMin, out nMax, OutData2, num);
						AddSeriesToChart(actualVelocityText, "", "XAxis", "YAxis", num, nMin, nMax, array, OutData2, actualvelcolor);
						text = ((text.Length <= 0) ? $"{commandAndActualVelocityText} (m unit/(ms))" : (text + "\n" + $"{commandAndActualVelocityText} (m unit/(ms))"));
					}
					else
					{
						FindVelocity(actualpos, out OutData2, num, gathertime);
						FindMinMax(out nMin, out nMax, OutData2, num);
						AddSeriesToChart(actualVelocityText, "", "XAxis", "YAxis", num, nMin, nMax, array, OutData2, actualvelcolor);
						text = ((text.Length <= 0) ? $"{actualVelocityText} (m unit/(ms))" : (text + "\n" + $"{actualVelocityText} (m unit/(ms))"));
					}
				}
				double[] OutData3;
				double[] OutData4;
				if (leftaxisitem[2] == 1)
				{
					FindAcceleration(commandedpos, out OutData3, num, gathertime);
					FindAcceleration(actualpos, out OutData4, num, gathertime);
					FindMinMax(out nMin, out nMax, OutData3, num);
					AddSeriesToChart(commandAccelerationText, "", "XAxis", "YAxis", num, nMin, nMax, array, OutData3, commandedacccolor);
					FindMinMax(out nMin, out nMax, OutData4, num);
					AddSeriesToChart(actualAccelerationText, "", "XAxis", "YAxis", num, nMin, nMax, array, OutData4, actualacccolor);
					text = ((text.Length <= 0) ? $"{commandAndActualAccelerationText} (m unit/(ms)^2)" : (text + "\n" + $"{commandAndActualAccelerationText} (m unit/(ms)^2)"));
				}
				if (leftaxisitem[3] == 1)
				{
					FindMinMax(out nMin, out nMax, servocommand, num);
					AddSeriesToChart(servoCommandText, "", "XAxis", "YAxis", num, nMin, nMax, array, servocommand, servocomandcolor);
					text = ((text.Length <= 0) ? $"{servoCommandText} (m unit)" : (text + "\n" + $"{servoCommandText} (m unit)"));
				}
				double[] output;
				if (leftaxisitem[4] == 1)
				{
					FindFollowingError(commandedpos, actualpos, out output, num);
					FindMinMax(out nMin, out nMax, output, num);
					AddSeriesToChart(followingErrorText, "", "XAxis", "YAxis", num, nMin, nMax, array, output, followingerrorcolor);
					text = ((text.Length <= 0) ? $"{followingErrorText} (m unit)" : (text + "\n" + $"{followingErrorText} (m unit)"));
				}
				if (rightaxisitem[0] == 1)
				{
					FindMinMax(out nMin, out nMax, commandedpos, num);
					AddSeriesToChart(commandPositionText, "", "XAxis", "Y2Axis", num, nMin, nMax, array, commandedpos, commandedposcolor);
					FindMinMax(out nMin, out nMax, actualpos, num);
					AddSeriesToChart(actualPositionText, "", "XAxis", "Y2Axis", num, nMin, nMax, array, actualpos, actualposcolor);
					text2 = $"{commandAndActualPositionText} (m unit)";
				}
				if (rightaxisitem[1] == 1)
				{
					if (!isopenloop)
					{
						FindVelocity(commandedpos, out OutData, num, gathertime);
						FindVelocity(actualpos, out OutData2, num, gathertime);
						FindMinMax(out nMin, out nMax, OutData, num);
						AddSeriesToChart(commandVelocityText, "", "XAxis", "Y2Axis", num, nMin, nMax, array, OutData, commandedvelcolor);
						FindMinMax(out nMin, out nMax, OutData2, num);
						AddSeriesToChart(actualVelocityText, "", "XAxis", "Y2Axis", num, nMin, nMax, array, OutData2, actualvelcolor);
						text2 = ((text2.Length <= 0) ? $"{commandAndActualVelocityText} (m unit/(ms))" : (text2 + "\n" + $"{commandAndActualVelocityText} (m unit/(ms))"));
					}
					else
					{
						FindVelocity(actualpos, out OutData2, num, gathertime);
						FindMinMax(out nMin, out nMax, OutData2, num);
						AddSeriesToChart(actualVelocityText, "", "XAxis", "Y2Axis", num, nMin, nMax, array, OutData2, actualvelcolor);
						text2 = ((text2.Length <= 0) ? $"{actualVelocityText} (m unit/(ms))" : (text2 + "\n" + $"{actualVelocityText} (m unit/(ms))"));
					}
				}
				if (rightaxisitem[2] == 1)
				{
					FindAcceleration(commandedpos, out OutData3, num, gathertime);
					FindAcceleration(actualpos, out OutData4, num, gathertime);
					FindMinMax(out nMin, out nMax, OutData3, num);
					AddSeriesToChart(commandAccelerationText, "", "XAxis", "Y2Axis", num, nMin, nMax, array, OutData3, commandedacccolor);
					FindMinMax(out nMin, out nMax, OutData4, num);
					AddSeriesToChart(actualAccelerationText, "", "XAxis", "Y2Axis", num, nMin, nMax, array, OutData4, actualacccolor);
					text2 = ((text2.Length <= 0) ? $"{commandAndActualAccelerationText} (m unit/(ms)^2)" : (text2 + "\n" + $"{commandAndActualAccelerationText} (m unit/(ms)^2)"));
				}
				if (rightaxisitem[3] == 1)
				{
					FindMinMax(out nMin, out nMax, servocommand, num);
					AddSeriesToChart(servoCommandText, "", "XAxis", "Y2Axis", num, nMin, nMax, array, servocommand, servocomandcolor);
					text2 = ((text2.Length <= 0) ? $"{servoCommandText} (m unit)" : (text2 + "\n" + $"{servoCommandText} (m unit)"));
				}
				if (rightaxisitem[4] == 1)
				{
					FindFollowingError(commandedpos, actualpos, out output, num);
					FindMinMax(out nMin, out nMax, output, num);
					AddSeriesToChart(followingErrorText, "", "XAxis", "Y2Axis", num, nMin, nMax, array, output, followingerrorcolor);
					text2 = ((text2.Length <= 0) ? $"{followingErrorText} (m unit)" : (text2 + "\n" + $"{followingErrorText} (m unit)"));
				}
				myPane.YAxis.Title.Text = text;
				myPane.Y2Axis.Title.Text = text2;
				ChangeTunePlot(isfreqbasedplot, normalizedplot, leftaxisitem, rightaxisitem);
				myPane.YAxis.Scale.FontSpec.FontColor = fontColor;
				myPane.YAxis.Title.FontSpec.FontColor = fontColor2;
				myPane.Y2Axis.Scale.FontSpec.FontColor = fontColor3;
				myPane.Y2Axis.Title.FontSpec.FontColor = fontColor4;
				myPane.XAxis.Scale.FontSpec.FontColor = fontColor5;
				myPane.XAxis.Title.FontSpec.FontColor = fontColor6;
				zg1.AxisChange();
				zg1.Invalidate();
			}
			catch (Exception ex)
			{
				throw new Exception(ex.Message);
			}
		}

		public void LoadTuneGantryPlot(bool isTuneplot, bool issinesweepplot, bool islogarithmicsweep, double freqstart, double freqend, bool isopenloopplot, double[] CommandedPosition, double[] ActualPosition, double[] ServoCommand, double[] ActualPosition_gantry, double[] ServoCommand_gantry, double GatherSamplingTime, string statistics, string HorizantalAxisItem, string LeftAxisItem, string RightAxisItem, string Title, double initial_homeposition, double initial_homeposition_gantry, double initial_commandedpos, double Masterpos_gantry)
		{
			try
			{
				istuneplot = isTuneplot;
				isopenloop = isopenloopplot;
				toolStripMenuItem_Tools.Enabled = true;
				toolStripMenuItem_FFT.Checked = false;
				commandedpos = CommandedPosition;
				actualpos = ActualPosition;
				servocommand = ServoCommand;
				actualpos_gantry = ActualPosition_gantry;
				servocommand_gantry = ServoCommand_gantry;
				masterposition_gantry = Masterpos_gantry;
				gathertime = GatherSamplingTime;
				SampleTime = gathertime;
				stats = statistics;
				isgantry = true;
				issinesweep = issinesweepplot;
				islogaritmic = islogarithmicsweep;
				start_freq = freqstart;
				end_freq = freqend;
				srightaxisitem = RightAxisItem;
				if (_useAxisItems)
				{
					isfreqbasedplot = false;
					normalizedplot = 2;
					horizantalaxisitem = HorizantalAxisItem;
					sleftaxisitem = LeftAxisItem;
					leftaxisitem = new int[6];
					rightaxisitem = new int[6];
					if (sleftaxisitem == "Position")
					{
						leftaxisitem[0] = 1;
					}
					else
					{
						leftaxisitem[0] = 0;
					}
					if (sleftaxisitem == "Velocity")
					{
						leftaxisitem[1] = 1;
					}
					else
					{
						leftaxisitem[1] = 0;
					}
					if (sleftaxisitem == "Acceleration")
					{
						leftaxisitem[2] = 1;
					}
					else
					{
						leftaxisitem[2] = 0;
					}
					if (sleftaxisitem == "Servo Command")
					{
						leftaxisitem[3] = 1;
					}
					else
					{
						leftaxisitem[3] = 0;
					}
					if (sleftaxisitem == "Following Error")
					{
						leftaxisitem[4] = 1;
					}
					else
					{
						leftaxisitem[4] = 0;
					}
					leftaxisitem[5] = 0;
					if (srightaxisitem == "Position")
					{
						rightaxisitem[0] = 1;
					}
					else
					{
						rightaxisitem[0] = 0;
					}
					if (srightaxisitem == "Velocity")
					{
						rightaxisitem[1] = 1;
					}
					else
					{
						rightaxisitem[1] = 0;
					}
					if (srightaxisitem == "Acceleration")
					{
						rightaxisitem[2] = 1;
					}
					else
					{
						rightaxisitem[2] = 0;
					}
					if (srightaxisitem == "Servo Command")
					{
						rightaxisitem[3] = 1;
					}
					else
					{
						rightaxisitem[3] = 0;
					}
					if (srightaxisitem == "Following Error")
					{
						rightaxisitem[4] = 1;
					}
					else
					{
						rightaxisitem[4] = 0;
					}
					rightaxisitem[5] = 0;
				}
				title = Title;
				homeposition = initial_homeposition;
				homeposition_gantry = initial_homeposition_gantry;
				cmdposinitial = initial_commandedpos;
				movingaveragefiltered = false;
				InitialChart(title);
				double[] array = new double[commandedpos.Length];
				double[] array2 = new double[commandedpos.Length];
				for (int i = 0; i < commandedpos.Length; i++)
				{
					array2[i] = commandedpos[i] + masterposition_gantry;
					array[i] = (double)i * gathertime;
				}
				timeinms = array;
				SetXAxisTitle(stats);
				myPane.XAxis.MajorGrid.IsVisible = true;
				int num = commandedpos.Length;
				double nMin = 0.0;
				double nMax = 0.0;
				string text = "";
				string text2 = "";
				Color fontColor = myPane.YAxis.Scale.FontSpec.FontColor;
				Color fontColor2 = myPane.YAxis.Title.FontSpec.FontColor;
				Color fontColor3 = myPane.Y2Axis.Scale.FontSpec.FontColor;
				Color fontColor4 = myPane.Y2Axis.Title.FontSpec.FontColor;
				Color fontColor5 = myPane.XAxis.Scale.FontSpec.FontColor;
				Color fontColor6 = myPane.XAxis.Title.FontSpec.FontColor;
				if (leftaxisitem[0] == 1)
				{
					FindMinMax(out nMin, out nMax, commandedpos, num);
					AddSeriesToChart(commandPositionText, "", "XAxis", "YAxis", num, nMin, nMax, array, commandedpos, commandedposcolor);
					FindMinMax(out nMin, out nMax, actualpos, num);
					AddSeriesToChart(actualPositionText, "", "XAxis", "YAxis", num, nMin, nMax, array, actualpos, actualposcolor);
					FindMinMax(out nMin, out nMax, array2, num);
					AddSeriesToChart(commandPositionGantryFollowerText, "", "XAxis", "YAxis", num, nMin, nMax, array, array2, gantrycommandedposcolor);
					FindMinMax(out nMin, out nMax, actualpos_gantry, num);
					AddSeriesToChart(gantryPositionText, "", "XAxis", "YAxis", num, nMin, nMax, array, actualpos_gantry, gantryactualposcolor);
					text = $"{commandAndActualPositionText} (m unit)";
				}
				double[] OutData;
				double[] OutData2;
				double[] OutData3;
				if (leftaxisitem[1] == 1)
				{
					if (!isopenloop)
					{
						FindVelocity(commandedpos, out OutData, num, gathertime);
						FindVelocity(actualpos, out OutData2, num, gathertime);
						FindVelocity(actualpos_gantry, out OutData3, num, gathertime);
						FindMinMax(out nMin, out nMax, OutData, num);
						AddSeriesToChart(commandVelocityText, "", "XAxis", "YAxis", num, nMin, nMax, array, OutData, commandedvelcolor);
						FindMinMax(out nMin, out nMax, OutData2, num);
						AddSeriesToChart(actualVelocityText, "", "XAxis", "YAxis", num, nMin, nMax, array, OutData2, actualvelcolor);
						FindMinMax(out nMin, out nMax, OutData3, num);
						AddSeriesToChart(actualVelocityGantryFollowerText, "", "XAxis", "YAxis", num, nMin, nMax, array, OutData3, gantryactualvelcolor);
						text = ((text.Length <= 0) ? $"{commandAndActualVelocityText} (m unit/(ms))" : (text + "\n" + $"{commandAndActualVelocityText} (m unit/(ms))"));
					}
					else
					{
						FindVelocity(actualpos, out OutData2, num, gathertime);
						FindVelocity(actualpos_gantry, out OutData3, num, gathertime);
						FindMinMax(out nMin, out nMax, OutData2, num);
						AddSeriesToChart(actualVelocityText, "", "XAxis", "YAxis", num, nMin, nMax, array, OutData2, actualvelcolor);
						FindMinMax(out nMin, out nMax, OutData3, num);
						AddSeriesToChart(actualVelocityGantryFollowerText, "", "XAxis", "YAxis", num, nMin, nMax, array, OutData3, gantryactualvelcolor);
						text = ((text.Length <= 0) ? $"{actualVelocityText} (m unit/(ms))" : (text + "\n" + $"{actualVelocityText} (m unit/(ms))"));
					}
				}
				double[] OutData4;
				double[] OutData5;
				double[] OutData6;
				if (leftaxisitem[2] == 1)
				{
					FindAcceleration(commandedpos, out OutData4, num, gathertime);
					FindAcceleration(actualpos, out OutData5, num, gathertime);
					FindAcceleration(actualpos_gantry, out OutData6, num, gathertime);
					FindMinMax(out nMin, out nMax, OutData4, num);
					AddSeriesToChart(commandAccelerationText, "", "XAxis", "YAxis", num, nMin, nMax, array, OutData4, commandedacccolor);
					FindMinMax(out nMin, out nMax, OutData5, num);
					AddSeriesToChart(actualAccelerationText, "", "XAxis", "YAxis", num, nMin, nMax, array, OutData5, actualacccolor);
					FindMinMax(out nMin, out nMax, OutData6, num);
					AddSeriesToChart(actualAccelerationGantryFollowerText, "", "XAxis", "YAxis", num, nMin, nMax, array, OutData6, gantryactualacccolor);
					text = ((text.Length <= 0) ? $"{commandAndActualAccelerationText} (m unit/(ms)^2)" : (text + "\n" + $"{commandAndActualAccelerationText} (m unit/(ms)^2)"));
				}
				if (leftaxisitem[3] == 1)
				{
					FindMinMax(out nMin, out nMax, servocommand, num);
					AddSeriesToChart(servoCommandText, "", "XAxis", "YAxis", num, nMin, nMax, array, servocommand, servocomandcolor);
					FindMinMax(out nMin, out nMax, servocommand_gantry, num);
					AddSeriesToChart(servoCommandGantryFollowerText, "", "XAxis", "YAxis", num, nMin, nMax, array, servocommand_gantry, gantryservocomandcolor);
					text = ((text.Length <= 0) ? $"{servoCommandText} (m unit)" : (text + "\n" + $"{servoCommandText} (m unit)"));
				}
				double[] output;
				double[] output2;
				if (leftaxisitem[4] == 1)
				{
					FindFollowingError(commandedpos, actualpos, out output, num);
					FindMinMax(out nMin, out nMax, output, num);
					AddSeriesToChart(followingErrorText, "", "XAxis", "YAxis", num, nMin, nMax, array, output, followingerrorcolor);
					FindFollowingError(array2, actualpos_gantry, out output2, num);
					FindMinMax(out nMin, out nMax, output2, num);
					AddSeriesToChart(followingErrorGantryFollowerText, "", "XAxis", "YAxis", num, nMin, nMax, array, output2, gantryfollowererrorcolor);
					text = ((text.Length <= 0) ? $"{followingErrorText} (m unit)" : (text + "\n" + $"{followingErrorText} (m unit)"));
				}
				if (leftaxisitem[5] == 1)
				{
					FindFollowingError(commandedpos, actualpos, out output, num);
					FindFollowingError(array2, actualpos_gantry, out output2, num);
					FindFollowingError(output, output2, out output, num);
					FindMinMax(out nMin, out nMax, output, num);
					AddSeriesToChart(gantryFollowingErrorText, "", "XAxis", "YAxis", num, nMin, nMax, array, output, Color.Yellow);
					text = ((text.Length <= 0) ? $"{gantryFollowingErrorText} (m unit)" : (text + "\n" + $"{gantryFollowingErrorText} (m unit)"));
				}
				if (rightaxisitem[0] == 1)
				{
					FindMinMax(out nMin, out nMax, commandedpos, num);
					AddSeriesToChart(commandPositionText, "", "XAxis", "Y2Axis", num, nMin, nMax, array, commandedpos, commandedposcolor);
					FindMinMax(out nMin, out nMax, actualpos, num);
					AddSeriesToChart(actualPositionText, "", "XAxis", "Y2Axis", num, nMin, nMax, array, actualpos, actualposcolor);
					FindMinMax(out nMin, out nMax, array2, num);
					AddSeriesToChart(commandPositionGantryFollowerText, "", "XAxis", "Y2Axis", num, nMin, nMax, array, array2, gantrycommandedposcolor);
					FindMinMax(out nMin, out nMax, actualpos_gantry, num);
					AddSeriesToChart(gantryPositionText, "", "XAxis", "Y2Axis", num, nMin, nMax, array, actualpos_gantry, gantryactualposcolor);
					text2 = $"{commandAndActualPositionText} (m unit)";
				}
				if (rightaxisitem[1] == 1)
				{
					if (!isopenloop)
					{
						FindVelocity(commandedpos, out OutData, num, gathertime);
						FindVelocity(actualpos, out OutData2, num, gathertime);
						FindVelocity(actualpos_gantry, out OutData3, num, gathertime);
						FindMinMax(out nMin, out nMax, OutData, num);
						AddSeriesToChart(commandVelocityText, "", "XAxis", "Y2Axis", num, nMin, nMax, array, OutData, commandedvelcolor);
						FindMinMax(out nMin, out nMax, OutData2, num);
						AddSeriesToChart(actualVelocityText, "", "XAxis", "Y2Axis", num, nMin, nMax, array, OutData2, actualvelcolor);
						FindMinMax(out nMin, out nMax, OutData3, num);
						AddSeriesToChart(actualVelocityGantryFollowerText, "", "XAxis", "Y2Axis", num, nMin, nMax, array, OutData3, gantryactualvelcolor);
						text2 = ((text2.Length <= 0) ? $"{commandAndActualVelocityText} (m unit/(ms))" : (text2 + "\n" + $"{commandAndActualVelocityText} (m unit/(ms))"));
					}
					else
					{
						FindVelocity(actualpos, out OutData2, num, gathertime);
						FindVelocity(actualpos_gantry, out OutData3, num, gathertime);
						FindMinMax(out nMin, out nMax, OutData2, num);
						AddSeriesToChart(actualVelocityText, "", "XAxis", "Y2Axis", num, nMin, nMax, array, OutData2, actualvelcolor);
						FindMinMax(out nMin, out nMax, OutData3, num);
						AddSeriesToChart(actualVelocityGantryFollowerText, "", "XAxis", "YAxis", num, nMin, nMax, array, OutData3, gantryactualvelcolor);
						text2 = ((text2.Length <= 0) ? $"{actualVelocityText} (m unit/(ms))" : (text2 + "\n" + $"{actualVelocityText} (m unit/(ms))"));
					}
				}
				if (rightaxisitem[2] == 1)
				{
					FindAcceleration(commandedpos, out OutData4, num, gathertime);
					FindAcceleration(actualpos, out OutData5, num, gathertime);
					FindAcceleration(actualpos_gantry, out OutData6, num, gathertime);
					FindMinMax(out nMin, out nMax, OutData4, num);
					AddSeriesToChart(commandAccelerationText, "", "XAxis", "Y2Axis", num, nMin, nMax, array, OutData4, commandedacccolor);
					FindMinMax(out nMin, out nMax, OutData5, num);
					AddSeriesToChart(actualAccelerationText, "", "XAxis", "Y2Axis", num, nMin, nMax, array, OutData5, actualacccolor);
					FindMinMax(out nMin, out nMax, OutData6, num);
					AddSeriesToChart(actualAccelerationGantryFollowerText, "", "XAxis", "YAxis", num, nMin, nMax, array, OutData6, gantryactualacccolor);
					text2 = ((text2.Length <= 0) ? $"{commandAndActualAccelerationText} (m unit/(ms)^2)" : (text2 + "\n" + $"{commandAndActualAccelerationText} (m unit/(ms)^2)"));
				}
				if (rightaxisitem[3] == 1)
				{
					FindMinMax(out nMin, out nMax, servocommand, num);
					AddSeriesToChart(servoCommandText, "", "XAxis", "Y2Axis", num, nMin, nMax, array, servocommand, servocomandcolor);
					FindMinMax(out nMin, out nMax, servocommand_gantry, num);
					AddSeriesToChart(servoCommandGantryFollowerText, "", "XAxis", "Y2Axis", num, nMin, nMax, array, servocommand_gantry, gantryservocomandcolor);
					text2 = ((text2.Length <= 0) ? $"{servoCommandText} (m unit)" : (text2 + "\n" + $"{servoCommandText} (m unit)"));
				}
				if (rightaxisitem[4] == 1)
				{
					FindFollowingError(commandedpos, actualpos, out output, num);
					FindMinMax(out nMin, out nMax, output, num);
					AddSeriesToChart(followingErrorText, "", "XAxis", "Y2Axis", num, nMin, nMax, array, output, followingerrorcolor);
					FindFollowingError(array2, actualpos_gantry, out output2, num);
					FindMinMax(out nMin, out nMax, output2, num);
					AddSeriesToChart(followingErrorGantryFollowerText, "", "XAxis", "Y2Axis", num, nMin, nMax, array, output2, gantryfollowererrorcolor);
					text2 = ((text2.Length <= 0) ? $"{followingErrorText} (m unit)" : (text2 + "\n" + $"{followingErrorText} (m unit)"));
				}
				if (rightaxisitem[5] == 1)
				{
					FindFollowingError(commandedpos, actualpos, out output, num);
					FindFollowingError(array2, actualpos_gantry, out output2, num);
					FindFollowingError(output, output2, out output, num);
					FindMinMax(out nMin, out nMax, output, num);
					AddSeriesToChart(gantryFollowingErrorText, "", "XAxis", "Y2Axis", num, nMin, nMax, array, output, gantryererrorcolor);
					text2 = ((text2.Length <= 0) ? $"{gantryFollowingErrorText} (m unit)" : (text2 + "\n" + $"{gantryFollowingErrorText} (m unit)"));
				}
				myPane.YAxis.Title.FontSpec.FontColor = Color.White;
				myPane.YAxis.Title.Text = text;
				myPane.Y2Axis.Title.FontSpec.FontColor = Color.White;
				myPane.Y2Axis.Title.Text = text2;
				ChangeTunePlot(isfreqbasedplot, normalizedplot, leftaxisitem, rightaxisitem);
				myPane.YAxis.Scale.FontSpec.FontColor = fontColor;
				myPane.YAxis.Title.FontSpec.FontColor = fontColor2;
				myPane.Y2Axis.Scale.FontSpec.FontColor = fontColor3;
				myPane.Y2Axis.Title.FontSpec.FontColor = fontColor4;
				myPane.XAxis.Scale.FontSpec.FontColor = fontColor5;
				myPane.XAxis.Title.FontSpec.FontColor = fontColor6;
				zg1.AxisChange();
				zg1.Invalidate();
			}
			catch (Exception ex)
			{
				throw new Exception(ex.Message);
			}
		}

		public void ChangeTunePlot(bool isfreqbased, int normalized, int[] LeftAxisItems, int[] RightAxisItems)
		{
			try
			{
				toolStripMenuItem_FFT.Checked = false;
				isfreqbasedplot = isfreqbased;
				normalizedplot = normalized;
				leftaxisitem = LeftAxisItems;
				rightaxisitem = RightAxisItems;
				double[] array = new double[commandedpos.Length];
				double[] array2 = new double[commandedpos.Length];
				double[] array3 = new double[commandedpos.Length];
				if (normalizedplot == 1)
				{
					for (int i = 0; i < commandedpos.Length; i++)
					{
						array3[i] = commandedpos[i] - cmdposinitial;
						array[i] = actualpos[i] - actualpos[0];
						if (isgantry)
						{
							array2[i] = actualpos_gantry[i] - actualpos_gantry[0];
						}
					}
				}
				else if (normalizedplot == 2)
				{
					for (int j = 0; j < commandedpos.Length; j++)
					{
						array3[j] = commandedpos[j] - homeposition;
						array[j] = actualpos[j] - homeposition;
						if (isgantry)
						{
							array2[j] = actualpos_gantry[j] - homeposition_gantry;
						}
					}
				}
				else
				{
					for (int k = 0; k < commandedpos.Length; k++)
					{
						array3[k] = 0.0;
						array[k] = 0.0;
						if (isgantry)
						{
							array2[k] = 0.0;
						}
					}
				}
				double[] array4 = new double[commandedpos.Length];
				double num = 0.0;
				double num2 = end_freq / start_freq;
				double num3 = Convert.ToDouble(commandedpos.Length);
				if (isfreqbasedplot)
				{
					for (int l = 0; l < commandedpos.Length; l++)
					{
						if (!islogaritmic)
						{
							array4[l] = start_freq + (double)l * (end_freq - start_freq) / (double)commandedpos.Length;
							continue;
						}
						num = Convert.ToDouble((double)l / num3);
						array4[l] = start_freq * Math.Pow(num2, num);
					}
					myPane.XAxis.Title.Text = $"{frequencyText} (Hz)";
				}
				else
				{
					for (int m = 0; m < commandedpos.Length; m++)
					{
						array4[m] = (double)m * gathertime;
					}
					SetXAxisTitle(stats);
				}
				double[] array5 = new double[commandedpos.Length];
				for (int n = 0; n < commandedpos.Length; n++)
				{
					array5[n] = commandedpos[n] + masterposition_gantry;
				}
				string text = "";
				string text2 = "";
				zg1.GraphPane.CurveList.Clear();
				myPane.XAxis.MajorGrid.IsVisible = true;
				int num4 = commandedpos.Length;
				double nMin = 0.0;
				double nMax = 0.0;
				if (leftaxisitem[0] == 1)
				{
					if (normalizedplot == 0)
					{
						if (!isopenloop)
						{
							FindMinMax(out nMin, out nMax, commandedpos, num4);
							AddSeriesToChart(commandPositionText, "", "XAxis", "YAxis", num4, nMin, nMax, array4, commandedpos, commandedposcolor);
						}
						if (isgantry)
						{
							if (!isopenloop)
							{
								FindMinMax(out nMin, out nMax, array5, num4);
								AddSeriesToChart(commandPositionGantryFollowerText, "", "XAxis", "YAxis", num4, nMin, nMax, array4, array5, gantrycommandedposcolor);
							}
							FindMinMax(out nMin, out nMax, actualpos, num4);
							if (!isopenloop)
							{
								AddSeriesToChart(actualPositionText, "", "XAxis", "YAxis", num4, nMin, nMax, array4, actualpos, actualposcolor);
								text = $"{commandAndActualPositionText} (m unit)";
							}
							else
							{
								AddSeriesToChart(actualPositionText, "", "XAxis", "YAxis", num4, nMin, nMax, array4, actualpos, actualposcolor);
								text = $"{actualPositionText} (m unit)";
							}
							FindMinMax(out nMin, out nMax, actualpos_gantry, num4);
							if (!isopenloop)
							{
								AddSeriesToChart(actualPositionGantryFollowerText, "", "XAxis", "YAxis", num4, nMin, nMax, array4, actualpos_gantry, gantrycommandedposcolor);
							}
							else
							{
								AddSeriesToChart(actualPositionGantryFollowerText, "", "XAxis", "YAxis", num4, nMin, nMax, array4, actualpos_gantry, gantryactualposcolor);
							}
						}
						else
						{
							FindMinMax(out nMin, out nMax, actualpos, num4);
							if (!isopenloop)
							{
								AddSeriesToChart(actualPositionText, "", "XAxis", "YAxis", num4, nMin, nMax, array4, actualpos, actualposcolor);
								text = $"{commandAndActualPositionText} (m unit)";
							}
							else
							{
								AddSeriesToChart(actualPositionText, "", "XAxis", "YAxis", num4, nMin, nMax, array4, actualpos, actualposcolor);
								text = $"{actualPositionText} (m unit)";
							}
						}
					}
					else if (normalizedplot == 1)
					{
						if (isgantry)
						{
							if (!isopenloop)
							{
								FindMinMax(out nMin, out nMax, array3, num4);
								AddSeriesToChart(commandPositionText, "", "XAxis", "YAxis", num4, nMin, nMax, array4, array3, commandedposcolor);
							}
							FindMinMax(out nMin, out nMax, array, num4);
							if (!isopenloop)
							{
								AddSeriesToChart(actualPositionText, "", "XAxis", "YAxis", num4, nMin, nMax, array4, array, actualposcolor);
								text = $"{commandAndActualPositionText} (m unit)\n{normalizedWrtToInitialValuesText}";
							}
							else
							{
								AddSeriesToChart(actualPositionText, "", "XAxis", "YAxis", num4, nMin, nMax, array4, array, actualposcolor);
								text = $"{actualPositionText} (m unit)\n{normalizedWrtToInitialValuesText}";
							}
							FindMinMax(out nMin, out nMax, array2, num4);
							if (!isopenloop)
							{
								AddSeriesToChart(actualPositionGantryFollowerText, "", "XAxis", "YAxis", num4, nMin, nMax, array4, array2, gantryactualposcolor);
							}
							else
							{
								AddSeriesToChart(actualPositionGantryFollowerText, "", "XAxis", "YAxis", num4, nMin, nMax, array4, array2, gantryactualposcolor);
							}
						}
						else
						{
							if (!isopenloop)
							{
								FindMinMax(out nMin, out nMax, array3, num4);
								AddSeriesToChart(commandPositionText, "", "XAxis", "YAxis", num4, nMin, nMax, array4, array3, commandedposcolor);
							}
							FindMinMax(out nMin, out nMax, array, num4);
							if (!isopenloop)
							{
								AddSeriesToChart(actualPositionText, "", "XAxis", "YAxis", num4, nMin, nMax, array4, array, actualposcolor);
								text = $"{commandAndActualPositionText} (m unit)\n{normalizedWrtToInitialValuesText}";
							}
							else
							{
								AddSeriesToChart(actualPositionText, "", "XAxis", "YAxis", num4, nMin, nMax, array4, array, actualposcolor);
								text = $"{actualPositionText} (m unit)\n{normalizedWrtToInitialValuesText}";
							}
						}
					}
					else if (isgantry)
					{
						if (!isopenloop)
						{
							FindMinMax(out nMin, out nMax, array3, num4);
							AddSeriesToChart(commandPositionText, "", "XAxis", "YAxis", num4, nMin, nMax, array4, array3, actualposcolor);
						}
						FindMinMax(out nMin, out nMax, array, num4);
						if (!isopenloop)
						{
							AddSeriesToChart(actualPositionText, "", "XAxis", "YAxis", num4, nMin, nMax, array4, array, actualposcolor);
							text = $"{commandAndActualPositionText} (m unit))\n{normalizedWrtToHomePositionText}";
						}
						else
						{
							AddSeriesToChart(actualPositionText, "", "XAxis", "YAxis", num4, nMin, nMax, array4, array, actualposcolor);
							text = $"{actualPositionText} (m unit))\n{normalizedWrtToHomePositionText}";
						}
						FindMinMax(out nMin, out nMax, array2, num4);
						if (!isopenloop)
						{
							AddSeriesToChart(actualPositionGantryFollowerText, "", "XAxis", "YAxis", num4, nMin, nMax, array4, array2, gantryactualposcolor);
						}
						else
						{
							AddSeriesToChart(actualPositionGantryFollowerText, "", "XAxis", "YAxis", num4, nMin, nMax, array4, array2, gantryactualposcolor);
						}
					}
					else
					{
						if (!isopenloop)
						{
							FindMinMax(out nMin, out nMax, array3, num4);
							AddSeriesToChart(commandPositionText, "", "XAxis", "YAxis", num4, nMin, nMax, array4, array3, commandedposcolor);
						}
						FindMinMax(out nMin, out nMax, array, num4);
						if (!isopenloop)
						{
							AddSeriesToChart(actualPositionText, "", "XAxis", "YAxis", num4, nMin, nMax, array4, array, actualposcolor);
							text = $"{commandAndActualPositionText} (m unit))\n{normalizedWrtToHomePositionText}";
						}
						else
						{
							AddSeriesToChart(actualPositionText, "", "XAxis", "YAxis", num4, nMin, nMax, array4, array, actualposcolor);
							text = $"{actualPositionText} (m unit))\n{normalizedWrtToHomePositionText}";
						}
					}
				}
				double[] OutData;
				double[] OutData2;
				double[] OutData3;
				if (leftaxisitem[1] == 1)
				{
					if (isgantry)
					{
						if (!isopenloop)
						{
							FindVelocity(commandedpos, out OutData, num4, gathertime);
							FindMinMax(out nMin, out nMax, OutData, num4);
							AddSeriesToChart(commandVelocityText, "", "XAxis", "YAxis", num4, nMin, nMax, array4, OutData, commandedvelcolor);
						}
						FindVelocity(actualpos, out OutData2, num4, gathertime);
						FindVelocity(actualpos_gantry, out OutData3, num4, gathertime);
						FindMinMax(out nMin, out nMax, OutData2, num4);
						if (!isopenloop)
						{
							AddSeriesToChart(actualVelocityText, "", "XAxis", "YAxis", num4, nMin, nMax, array4, OutData2, actualvelcolor);
							text = ((text.Length <= 0) ? $"{commandAndActualVelocityText} (m unit/(ms))" : (text + "\n" + $"{commandAndActualVelocityText} (m unit/(ms))"));
						}
						else
						{
							AddSeriesToChart(actualVelocityText, "", "XAxis", "YAxis", num4, nMin, nMax, array4, OutData2, actualvelcolor);
							text = ((text.Length <= 0) ? $"{actualVelocityText} (m unit/(ms))" : (text + "\n" + $"{actualVelocityText} (m unit/(ms))"));
						}
						FindMinMax(out nMin, out nMax, OutData3, num4);
						if (!isopenloop)
						{
							AddSeriesToChart(actualVelocityGantryFollowerText, "", "XAxis", "YAxis", num4, nMin, nMax, array4, OutData3, gantryactualvelcolor);
						}
						else
						{
							AddSeriesToChart(actualVelocityGantryFollowerText, "", "XAxis", "YAxis", num4, nMin, nMax, array4, OutData3, gantryactualvelcolor);
						}
					}
					else
					{
						if (!isopenloop)
						{
							FindVelocity(commandedpos, out OutData, num4, gathertime);
							FindMinMax(out nMin, out nMax, OutData, num4);
							AddSeriesToChart(commandVelocityText, "", "XAxis", "YAxis", num4, nMin, nMax, array4, OutData, commandedvelcolor);
						}
						FindVelocity(actualpos, out OutData2, num4, gathertime);
						FindMinMax(out nMin, out nMax, OutData2, num4);
						if (!isopenloop)
						{
							AddSeriesToChart(actualVelocityText, "", "XAxis", "YAxis", num4, nMin, nMax, array4, OutData2, actualvelcolor);
							text = ((text.Length <= 0) ? $"{commandAndActualVelocityText} (m unit/(ms))" : (text + "\n" + $"{commandAndActualVelocityText} (m unit/(ms))"));
						}
						else
						{
							AddSeriesToChart(actualVelocityText, "", "XAxis", "YAxis", num4, nMin, nMax, array4, OutData2, actualvelcolor);
							text = ((text.Length <= 0) ? $"{actualVelocityText} (m unit/(ms))" : (text + "\n" + $"{actualVelocityText} (m unit/(ms))"));
						}
					}
				}
				double[] OutData4;
				double[] OutData5;
				double[] OutData6;
				if (leftaxisitem[2] == 1)
				{
					if (isgantry)
					{
						if (!isopenloop)
						{
							FindAcceleration(commandedpos, out OutData4, num4, gathertime);
							FindMinMax(out nMin, out nMax, OutData4, num4);
							AddSeriesToChart(commandAccelerationText, $"{commandAccelerationText} (m unit/(ms)^2)", "XAxis", "YAxis", num4, nMin, nMax, array4, OutData4, commandedacccolor);
						}
						FindAcceleration(actualpos, out OutData5, num4, gathertime);
						FindAcceleration(actualpos_gantry, out OutData6, num4, gathertime);
						FindMinMax(out nMin, out nMax, OutData5, num4);
						if (!isopenloop)
						{
							AddSeriesToChart(actualAccelerationText, "", "XAxis", "YAxis", num4, nMin, nMax, array4, OutData5, actualacccolor);
							text = ((text.Length <= 0) ? $"{commandAndActualAccelerationText} (m unit/(ms)^2)" : (text + "\n" + $"{commandAndActualAccelerationText} (m unit/(ms)^2)"));
						}
						else
						{
							AddSeriesToChart(actualAccelerationText, "", "XAxis", "YAxis", num4, nMin, nMax, array4, OutData5, actualacccolor);
							text = ((text.Length <= 0) ? $"{actualAccelerationText} (m unit/(ms)^2)" : (text + "\n" + $"{actualAccelerationText} (m unit/(ms)^2)"));
						}
						FindMinMax(out nMin, out nMax, OutData6, num4);
						if (!isopenloop)
						{
							AddSeriesToChart(actualAccelerationGantryFollowerText, $"{commandAndActualAccelerationText} (m unit/(ms)^2)", "XAxis", "YAxis", num4, nMin, nMax, array4, OutData6, gantryactualacccolor);
						}
						else
						{
							AddSeriesToChart(actualAccelerationGantryFollowerText, $"{actualAccelerationText} (m unit/(ms)^2)", "XAxis", "YAxis", num4, nMin, nMax, array4, OutData6, gantryactualacccolor);
						}
					}
					else
					{
						if (!isopenloop)
						{
							FindAcceleration(commandedpos, out OutData4, num4, gathertime);
							FindMinMax(out nMin, out nMax, OutData4, num4);
							AddSeriesToChart(commandAccelerationText, "", "XAxis", "YAxis", num4, nMin, nMax, array4, OutData4, actualacccolor);
						}
						FindAcceleration(actualpos, out OutData5, num4, gathertime);
						FindMinMax(out nMin, out nMax, OutData5, num4);
						if (!isopenloop)
						{
							AddSeriesToChart(actualAccelerationText, "", "XAxis", "YAxis", num4, nMin, nMax, array4, OutData5, actualacccolor);
							text = ((text.Length <= 0) ? $"{commandAndActualAccelerationText} (m unit/(ms)^2)" : (text + "\n" + $"{commandAndActualAccelerationText} (m unit/(ms)^2)"));
						}
						else
						{
							AddSeriesToChart(actualAccelerationText, "", "XAxis", "YAxis", num4, nMin, nMax, array4, OutData5, actualacccolor);
							text = ((text.Length <= 0) ? $"{actualAccelerationText} (m unit/(ms)^2)" : (text + "\n" + $"{actualAccelerationText} (m unit/(ms)^2)"));
						}
					}
				}
				if (leftaxisitem[3] == 1)
				{
					if (isgantry)
					{
						FindMinMax(out nMin, out nMax, servocommand, num4);
						AddSeriesToChart(servoCommandText, "", "XAxis", "YAxis", num4, nMin, nMax, array4, servocommand, servocomandcolor);
						FindMinMax(out nMin, out nMax, servocommand_gantry, num4);
						AddSeriesToChart(servoCommandGantryFollowerText, "", "XAxis", "YAxis", num4, nMin, nMax, array4, servocommand_gantry, gantryservocomandcolor);
						text = ((text.Length <= 0) ? $"{servoCommandText} (m unit)\n{servoCommandGantryFollowerText}(m unit)" : (text + "\n" + $"{servoCommandText} (m unit)\n{servoCommandGantryFollowerText}(m unit)"));
					}
					else
					{
						FindMinMax(out nMin, out nMax, servocommand, num4);
						AddSeriesToChart(servoCommandText, "", "XAxis", "YAxis", num4, nMin, nMax, array4, servocommand, servocomandcolor);
						text = ((text.Length <= 0) ? $"{servoCommandText} (m unit)" : (text + "\n" + $"{servoCommandText} (m unit)"));
					}
				}
				double[] output;
				double[] output2;
				if (leftaxisitem[4] == 1)
				{
					if (isgantry)
					{
						FindFollowingError(commandedpos, actualpos, out output, num4);
						FindMinMax(out nMin, out nMax, output, num4);
						AddSeriesToChart(followingErrorText, "", "XAxis", "YAxis", num4, nMin, nMax, array4, output, followingerrorcolor);
						FindFollowingError(array5, actualpos_gantry, out output2, num4);
						FindMinMax(out nMin, out nMax, output2, num4);
						AddSeriesToChart(followingErrorGantryFollowerText, "", "XAxis", "YAxis", num4, nMin, nMax, array4, output2, gantryfollowererrorcolor);
					}
					else
					{
						FindFollowingError(commandedpos, actualpos, out output, num4);
						FindMinMax(out nMin, out nMax, output, num4);
						AddSeriesToChart(followingErrorText, "", "XAxis", "YAxis", num4, nMin, nMax, array4, output, followingerrorcolor);
					}
					text = ((text.Length <= 0) ? $"{followingErrorText} (m unit)" : (text + "\n" + $"{followingErrorText} (m unit)"));
				}
				if (leftaxisitem[5] == 1)
				{
					FindFollowingError(commandedpos, actualpos, out output, num4);
					FindFollowingError(array5, actualpos_gantry, out output2, num4);
					FindFollowingError(output, output2, out output, num4);
					FindMinMax(out nMin, out nMax, output, num4);
					AddSeriesToChart(gantryFollowingErrorText, "", "XAxis", "YAxis", num4, nMin, nMax, array4, output, gantryererrorcolor);
					text = ((text.Length <= 0) ? $"{gantryFollowingErrorText} (m unit)" : (text + "\n" + $"{gantryFollowingErrorText} (m unit)"));
				}
				if (rightaxisitem[0] == 1)
				{
					if (normalizedplot == 0)
					{
						if (!isopenloop)
						{
							FindMinMax(out nMin, out nMax, commandedpos, num4);
							AddSeriesToChart(commandPositionText, "", "XAxis", "Y2Axis", num4, nMin, nMax, array4, commandedpos, commandedposcolor);
						}
						if (isgantry)
						{
							if (!isopenloop)
							{
								FindMinMax(out nMin, out nMax, array5, num4);
								AddSeriesToChart(commandPositionGantryFollowerText, "", "XAxis", "Y2Axis", num4, nMin, nMax, array4, array5, gantrycommandedposcolor);
							}
							FindMinMax(out nMin, out nMax, actualpos, num4);
							if (!isopenloop)
							{
								AddSeriesToChart(actualPositionText, "", "XAxis", "Y2Axis", num4, nMin, nMax, array4, actualpos, actualposcolor);
								text2 = $"{commandAndActualPositionText} (m unit)";
							}
							else
							{
								AddSeriesToChart(actualPositionText, "", "XAxis", "Y2Axis", num4, nMin, nMax, array4, actualpos, actualposcolor);
								text2 = $"{actualPositionText} (m unit)";
							}
							FindMinMax(out nMin, out nMax, actualpos_gantry, num4);
							if (!isopenloop)
							{
								AddSeriesToChart(actualPositionGantryFollowerText, "", "XAxis", "Y2Axis", num4, nMin, nMax, array4, actualpos_gantry, gantrycommandedposcolor);
							}
							else
							{
								AddSeriesToChart(actualPositionGantryFollowerText, "", "XAxis", "Y2Axis", num4, nMin, nMax, array4, actualpos_gantry, gantryactualposcolor);
							}
						}
						else
						{
							FindMinMax(out nMin, out nMax, actualpos, num4);
							if (!isopenloop)
							{
								AddSeriesToChart(actualPositionText, "", "XAxis", "Y2Axis", num4, nMin, nMax, array4, actualpos, actualposcolor);
								text2 = $"{commandAndActualPositionText} (m unit)";
							}
							else
							{
								AddSeriesToChart(actualPositionText, "", "XAxis", "Y2Axis", num4, nMin, nMax, array4, actualpos, actualposcolor);
								text2 = $"{actualPositionText} (m unit)";
							}
						}
					}
					else if (normalizedplot == 1)
					{
						if (isgantry)
						{
							if (!isopenloop)
							{
								FindMinMax(out nMin, out nMax, array3, num4);
								AddSeriesToChart(commandPositionText, "", "XAxis", "Y2Axis", num4, nMin, nMax, array4, array3, commandedposcolor);
							}
							FindMinMax(out nMin, out nMax, array, num4);
							if (!isopenloop)
							{
								AddSeriesToChart(actualPositionText, "", "XAxis", "Y2Axis", num4, nMin, nMax, array4, array, actualposcolor);
								text2 = $"{commandAndActualPositionText} (m unit)\n{normalizedWrtToInitialValuesText}";
							}
							else
							{
								AddSeriesToChart(actualPositionText, "", "XAxis", "Y2Axis", num4, nMin, nMax, array4, array, actualposcolor);
								text2 = $"{actualPositionText} (m unit)\n{normalizedWrtToInitialValuesText}";
							}
							FindMinMax(out nMin, out nMax, array2, num4);
							if (!isopenloop)
							{
								AddSeriesToChart(actualPositionGantryFollowerText, "", "XAxis", "Y2Axis", num4, nMin, nMax, array4, array2, gantryactualposcolor);
							}
							else
							{
								AddSeriesToChart(actualPositionGantryFollowerText, "", "XAxis", "Y2Axis", num4, nMin, nMax, array4, array2, gantryactualposcolor);
							}
						}
						else
						{
							if (!isopenloop)
							{
								FindMinMax(out nMin, out nMax, array3, num4);
								AddSeriesToChart(commandPositionText, "", "XAxis", "Y2Axis", num4, nMin, nMax, array4, array3, commandedposcolor);
							}
							FindMinMax(out nMin, out nMax, array, num4);
							if (!isopenloop)
							{
								AddSeriesToChart(actualPositionText, "", "XAxis", "Y2Axis", num4, nMin, nMax, array4, array, actualposcolor);
								text2 = $"{commandAndActualPositionText} (m unit)\n{normalizedWrtToInitialValuesText}";
							}
							else
							{
								AddSeriesToChart(actualPositionText, "", "XAxis", "Y2Axis", num4, nMin, nMax, array4, array, actualposcolor);
								text2 = $"{actualPositionText} (m unit)\n{normalizedWrtToInitialValuesText}";
							}
						}
					}
					else if (isgantry)
					{
						if (!isopenloop)
						{
							FindMinMax(out nMin, out nMax, array3, num4);
							AddSeriesToChart(commandPositionText, "", "XAxis", "Y2Axis", num4, nMin, nMax, array4, array3, actualposcolor);
						}
						FindMinMax(out nMin, out nMax, array, num4);
						if (!isopenloop)
						{
							AddSeriesToChart(actualPositionText, "", "XAxis", "Y2Axis", num4, nMin, nMax, array4, array, actualposcolor);
							text2 = $"{commandAndActualPositionText} (m unit))\n{normalizedWrtToHomePositionText}";
						}
						else
						{
							AddSeriesToChart(actualPositionText, "", "XAxis", "Y2Axis", num4, nMin, nMax, array4, array, actualposcolor);
							text2 = $"{actualPositionText} (m unit))\n{normalizedWrtToHomePositionText}";
						}
						FindMinMax(out nMin, out nMax, array2, num4);
						if (!isopenloop)
						{
							AddSeriesToChart(actualPositionGantryFollowerText, "", "XAxis", "Y2Axis", num4, nMin, nMax, array4, array2, gantryactualposcolor);
						}
						else
						{
							AddSeriesToChart(actualPositionGantryFollowerText, "", "XAxis", "Y2Axis", num4, nMin, nMax, array4, array2, gantryactualposcolor);
						}
					}
					else
					{
						if (!isopenloop)
						{
							FindMinMax(out nMin, out nMax, array3, num4);
							AddSeriesToChart(commandPositionText, "", "XAxis", "Y2Axis", num4, nMin, nMax, array4, array3, commandedposcolor);
						}
						FindMinMax(out nMin, out nMax, array, num4);
						if (!isopenloop)
						{
							AddSeriesToChart(actualPositionText, "", "XAxis", "Y2Axis", num4, nMin, nMax, array4, array, actualposcolor);
							text2 = $"{commandAndActualPositionText} (m unit))\n{normalizedWrtToHomePositionText}";
						}
						else
						{
							AddSeriesToChart(actualPositionText, "", "XAxis", "Y2Axis", num4, nMin, nMax, array4, array, actualposcolor);
							text2 = $"{actualPositionText} (m unit))\n{normalizedWrtToHomePositionText}";
						}
					}
				}
				if (rightaxisitem[1] == 1)
				{
					if (isgantry)
					{
						if (!isopenloop)
						{
							FindVelocity(commandedpos, out OutData, num4, gathertime);
							FindMinMax(out nMin, out nMax, OutData, num4);
							AddSeriesToChart(commandVelocityText, "", "XAxis", "Y2Axis", num4, nMin, nMax, array4, OutData, commandedvelcolor);
						}
						FindVelocity(actualpos, out OutData2, num4, gathertime);
						FindVelocity(actualpos_gantry, out OutData3, num4, gathertime);
						FindMinMax(out nMin, out nMax, OutData2, num4);
						if (!isopenloop)
						{
							AddSeriesToChart(actualVelocityText, "", "XAxis", "Y2Axis", num4, nMin, nMax, array4, OutData2, actualvelcolor);
							text2 = ((text2.Length <= 0) ? $"{commandAndActualVelocityText} (m unit/(ms))" : (text2 + "\n" + $"{commandAndActualVelocityText} (m unit/(ms))"));
						}
						else
						{
							AddSeriesToChart(actualVelocityText, "", "XAxis", "Y2Axis", num4, nMin, nMax, array4, OutData2, actualvelcolor);
							text2 = ((text2.Length <= 0) ? $"{actualVelocityText} (m unit/(ms))" : (text2 + "\n" + $"{actualVelocityText} (m unit/(ms))"));
						}
						FindMinMax(out nMin, out nMax, OutData3, num4);
						if (!isopenloop)
						{
							AddSeriesToChart(actualVelocityGantryFollowerText, "", "XAxis", "Y2Axis", num4, nMin, nMax, array4, OutData3, gantryactualvelcolor);
						}
						else
						{
							AddSeriesToChart(actualVelocityGantryFollowerText, "", "XAxis", "Y2Axis", num4, nMin, nMax, array4, OutData3, gantryactualvelcolor);
						}
					}
					else
					{
						if (!isopenloop)
						{
							FindVelocity(commandedpos, out OutData, num4, gathertime);
							FindMinMax(out nMin, out nMax, OutData, num4);
							AddSeriesToChart(commandVelocityText, "", "XAxis", "Y2Axis", num4, nMin, nMax, array4, OutData, commandedvelcolor);
						}
						FindVelocity(actualpos, out OutData2, num4, gathertime);
						FindMinMax(out nMin, out nMax, OutData2, num4);
						if (!isopenloop)
						{
							AddSeriesToChart(actualVelocityText, "", "XAxis", "Y2Axis", num4, nMin, nMax, array4, OutData2, actualvelcolor);
							text2 = ((text2.Length <= 0) ? $"{commandAndActualVelocityText} (m unit/(ms))" : (text2 + "\n" + $"{commandAndActualVelocityText} (m unit/(ms))"));
						}
						else
						{
							AddSeriesToChart(actualVelocityText, "", "XAxis", "Y2Axis", num4, nMin, nMax, array4, OutData2, actualvelcolor);
							text2 = ((text2.Length <= 0) ? $"{actualVelocityText} (m unit/(ms))" : (text2 + "\n" + $"{actualVelocityText} (m unit/(ms))"));
						}
					}
				}
				if (rightaxisitem[2] == 1)
				{
					if (isgantry)
					{
						if (!isopenloop)
						{
							FindAcceleration(commandedpos, out OutData4, num4, gathertime);
							FindMinMax(out nMin, out nMax, OutData4, num4);
							AddSeriesToChart(commandAccelerationText, $"{commandAccelerationText} (m unit/(ms)^2)", "XAxis", "Y2Axis", num4, nMin, nMax, array4, OutData4, commandedacccolor);
						}
						FindAcceleration(actualpos, out OutData5, num4, gathertime);
						FindAcceleration(actualpos_gantry, out OutData6, num4, gathertime);
						FindMinMax(out nMin, out nMax, OutData5, num4);
						if (!isopenloop)
						{
							AddSeriesToChart(commandAccelerationText, "", "XAxis", "Y2Axis", num4, nMin, nMax, array4, OutData5, actualacccolor);
							text2 = ((text2.Length <= 0) ? $"{commandAndActualAccelerationText} (m unit/(ms)^2)" : (text2 + "\n" + $"{commandAndActualAccelerationText} (m unit/(ms)^2)"));
						}
						else
						{
							AddSeriesToChart(actualAccelerationText, "", "XAxis", "Y2Axis", num4, nMin, nMax, array4, OutData5, actualacccolor);
							text2 = ((text2.Length <= 0) ? $"{actualAccelerationText} (m unit/(ms)^2)" : (text2 + "\n" + $"{actualAccelerationText} (m unit/(ms)^2)"));
						}
						FindMinMax(out nMin, out nMax, OutData6, num4);
						if (!isopenloop)
						{
							AddSeriesToChart(actualAccelerationGantryFollowerText, $"{commandAndActualAccelerationText} (m unit/(ms)^2)", "XAxis", "Y2Axis", num4, nMin, nMax, array4, OutData6, gantryactualacccolor);
						}
						else
						{
							AddSeriesToChart(actualAccelerationGantryFollowerText, $"{actualAccelerationText} (m unit/(ms)^2)", "XAxis", "Y2Axis", num4, nMin, nMax, array4, OutData6, gantryactualacccolor);
						}
					}
					else
					{
						if (!isopenloop)
						{
							FindAcceleration(commandedpos, out OutData4, num4, gathertime);
							FindMinMax(out nMin, out nMax, OutData4, num4);
							AddSeriesToChart(commandAccelerationText, "", "XAxis", "Y2Axis", num4, nMin, nMax, array4, OutData4, actualacccolor);
						}
						FindAcceleration(actualpos, out OutData5, num4, gathertime);
						FindMinMax(out nMin, out nMax, OutData5, num4);
						if (!isopenloop)
						{
							AddSeriesToChart(actualAccelerationText, "", "XAxis", "Y2Axis", num4, nMin, nMax, array4, OutData5, actualacccolor);
							text2 = ((text2.Length <= 0) ? $"{commandAndActualAccelerationText} (m unit/(ms)^2)" : (text2 + "\n" + $"{commandAndActualAccelerationText} (m unit/(ms)^2)"));
						}
						else
						{
							AddSeriesToChart(actualAccelerationText, "", "XAxis", "Y2Axis", num4, nMin, nMax, array4, OutData5, actualacccolor);
							text2 = ((text2.Length <= 0) ? $"{actualAccelerationText} (m unit/(ms)^2)" : (text2 + "\n" + $"{actualAccelerationText} (m unit/(ms)^2)"));
						}
					}
				}
				if (rightaxisitem[3] == 1)
				{
					if (isgantry)
					{
						FindMinMax(out nMin, out nMax, servocommand, num4);
						AddSeriesToChart(servoCommandText, "", "XAxis", "Y2Axis", num4, nMin, nMax, array4, servocommand, servocomandcolor);
						FindMinMax(out nMin, out nMax, servocommand_gantry, num4);
						AddSeriesToChart(servoCommandGantryFollowerText, "", "XAxis", "Y2Axis", num4, nMin, nMax, array4, servocommand_gantry, gantryservocomandcolor);
						text2 = ((text2.Length <= 0) ? $"{servoCommandText} (m unit)\n{servoCommandGantryFollowerText}(m unit)" : (text2 + "\n" + $"{servoCommandText} (m unit)\n{servoCommandGantryFollowerText}(m unit)"));
					}
					else
					{
						FindMinMax(out nMin, out nMax, servocommand, num4);
						AddSeriesToChart(servoCommandText, "", "XAxis", "Y2Axis", num4, nMin, nMax, array4, servocommand, servocomandcolor);
						text2 = ((text2.Length <= 0) ? $"{servoCommandText} (m unit)" : (text2 + "\n" + $"{servoCommandText} (m unit)"));
					}
				}
				if (rightaxisitem[4] == 1)
				{
					if (isgantry)
					{
						FindFollowingError(commandedpos, actualpos, out output, num4);
						FindMinMax(out nMin, out nMax, output, num4);
						AddSeriesToChart(followingErrorText, "", "XAxis", "Y2Axis", num4, nMin, nMax, array4, output, followingerrorcolor);
						FindFollowingError(array5, actualpos_gantry, out output2, num4);
						FindMinMax(out nMin, out nMax, output2, num4);
						AddSeriesToChart(followingErrorGantryFollowerText, "", "XAxis", "Y2Axis", num4, nMin, nMax, array4, output2, gantryfollowererrorcolor);
					}
					else
					{
						FindFollowingError(commandedpos, actualpos, out output, num4);
						FindMinMax(out nMin, out nMax, output, num4);
						AddSeriesToChart(followingErrorText, "", "XAxis", "Y2Axis", num4, nMin, nMax, array4, output, followingerrorcolor);
					}
					text2 = ((text2.Length <= 0) ? $"{followingErrorText} (m unit)" : (text2 + "\n" + $"{followingErrorText} (m unit)"));
				}
				if (rightaxisitem[5] == 1)
				{
					FindFollowingError(commandedpos, actualpos, out output, num4);
					FindFollowingError(array5, actualpos_gantry, out output2, num4);
					FindFollowingError(output, output2, out output, num4);
					FindMinMax(out nMin, out nMax, output, num4);
					AddSeriesToChart(gantryFollowingErrorText, "", "XAxis", "Y2Axis", num4, nMin, nMax, array4, output, gantryererrorcolor);
					text2 = ((text2.Length <= 0) ? $"{gantryFollowingErrorText} (m unit)" : (text2 + "\n" + $"{gantryFollowingErrorText} (m unit)"));
				}
				myPane.YAxis.Title.FontSpec.FontColor = Color.White;
				myPane.YAxis.Title.Text = text;
				myPane.Y2Axis.Title.FontSpec.FontColor = Color.White;
				myPane.Y2Axis.Title.Text = text2;
				zg1.AxisChange();
				zg1.Invalidate();
			}
			catch (Exception ex)
			{
				throw new Exception(ex.Message);
			}
		}

		public void LoadCurrentTunePlot(bool isTuneplot, bool isCurrentStepplot, double[] IdMeasured, double[] Timeinservocycles, double TsCurrent, string statistics, int xCol, int xRow, string Title)
		{
			try
			{
				istuneplot = isTuneplot;
				iscurrentstepplot = isCurrentStepplot;
				idmeasured = IdMeasured;
				timeinphasecycles = Timeinservocycles;
				stats = statistics;
				title = Title;
				tscurrent = TsCurrent;
				xrow = xRow;
				xcol = xCol;
				double nMin = 0.0;
				double nMax = 0.0;
				InitialChart(title);
				double[] outTimebase;
				AddTimebaseHorizontalToChart(stats, xRow, Timeinservocycles, out outTimebase, TsCurrent);
				FindMinMax(out nMin, out nMax, IdMeasured, xRow);
				AddSeriesToChart(actualCurrentText, $"{actualCurrentResponseText} (bits)", "XAxis", "YAxis", xRow, nMin, nMax, outTimebase, idmeasured, Color.IndianRed);
			}
			catch (Exception ex)
			{
				throw new Exception(ex.Message);
			}
		}

		public bool FindFollowingError(double[] d1, double[] d2, out double[] output, int number)
		{
			output = new double[number];
			for (int i = 0; i < number; i++)
			{
				output[i] = d1[i] - d2[i];
			}
			return true;
		}

		public void FindVelocity(double[] InData, out double[] OutData, int number, double sampleTime)
		{
			OutData = new double[number];
			if (sampleTime <= 0.0)
			{
				for (int i = 0; i < number; i++)
				{
					OutData[i] = 0.0;
				}
				MessageBox.Show(sampleTimeIsZeroText, firstDerivativeErrorText, MessageBoxButtons.OK, MessageBoxIcon.Hand);
			}
			else
			{
				if (InData == null || number <= 1)
				{
					return;
				}
				for (int j = 0; j < number; j++)
				{
					if (j == 0)
					{
						OutData[j] = (InData[j + 1] - InData[j]) / sampleTime;
					}
					else if (j == number - 1)
					{
						OutData[j] = OutData[j - 1];
					}
					else
					{
						OutData[j] = (InData[j + 1] - InData[j - 1]) * 0.5 / sampleTime;
					}
				}
			}
		}

		public bool FindAcceleration(double[] InData, out double[] OutData, int number, double sampleTime)
		{
			OutData = new double[number];
			if (sampleTime < 0.0)
			{
				for (int i = 0; i < number; i++)
				{
					OutData[i] = 0.0;
				}
				MessageBox.Show(sampleTimeIsZeroText, secondDerivativeErrorText, MessageBoxButtons.OK, MessageBoxIcon.Hand);
				return false;
			}
			if (InData == null)
			{
				return false;
			}
			if (number <= 1)
			{
				return false;
			}
			for (int j = 0; j < number; j++)
			{
				if (j == 0)
				{
					double num = InData[j + 2] + InData[j];
					double num2 = InData[j + 1];
					OutData[j] = (num - 2.0 * num2) / (sampleTime * sampleTime);
				}
				else if (j == number - 1)
				{
					OutData[j] = OutData[j - 1];
				}
				else
				{
					double num = InData[j + 1] + InData[j - 1];
					double num2 = InData[j];
					OutData[j] = (num - 2.0 * num2) / (sampleTime * sampleTime);
				}
			}
			return true;
		}

		public bool FindJerk(double[] InData, out double[] OutData, int number, double sampleTime)
		{
			OutData = new double[number];
			if (sampleTime < 0.0)
			{
				for (int i = 0; i < number; i++)
				{
					OutData[i] = 0.0;
				}
				MessageBox.Show(sampleTimeIsZeroText, thirdDerivativeErrorText, MessageBoxButtons.OK, MessageBoxIcon.Hand);
				return false;
			}
			for (int j = 2; j < number; j++)
			{
				double num = InData[j + 2] + 2.0 * InData[j - 1];
				double num2 = InData[j - 2] + 2.0 * InData[j + 1];
				OutData[j] = (num - num2 * 0.5) / (sampleTime * sampleTime);
			}
			OutData[0] = OutData[2];
			OutData[1] = OutData[2];
			OutData[number - 1] = OutData[number - 3];
			OutData[number - 2] = OutData[number - 3];
			return true;
		}

		public bool filter_MovingAverage(double[] InData, out double[] OutData, int number, int filterorder)
		{
			OutData = new double[number];
			for (int i = filterorder; i < number; i++)
			{
				OutData[i] = 0.0;
				for (int j = 0; j <= filterorder; j++)
				{
					OutData[i] += InData[i - j];
				}
				OutData[i] /= (double)(filterorder + 1);
			}
			for (int k = 0; k < filterorder; k++)
			{
				OutData[k] = OutData[filterorder];
			}
			return true;
		}

		public List<Color> GetCurrentSeriesColors()
		{
			List<Color> list = new List<Color>();
			foreach (LineItem curve in myPane.CurveList)
			{
				list.Add(curve.Color);
			}
			return list;
		}

		public void SetCurrentSeriesColors(List<Color> clist)
		{
			for (int i = 0; i < clist.Count && i < myPane.CurveList.Count; i++)
			{
				myPane.CurveList[i].Color = clist[i];
			}
		}

		private void SetLanguageTranslations()
		{
			ILanguageTranslationService service = ServiceManager.GetService<ILanguageTranslationService>();
			timeMillisecondsText = service.Translate("PPChartControl.TimeMilliseconds");
			timeSecondsText = service.Translate("PPChartControl.TimeSeconds");
			positionText = service.Translate("PPChartControl.Position");
			productNameText = service.Translate("Common.ProductName");
			plotText = service.Translate("PPChartControl.Plot");
			graphToolTipTextFormat = service.Translate("PPChartControl.GraphToolTipTextFormat");
			pageSetupText = service.Translate("PPChartControl.PageSetup");
			printPreviewText = service.Translate("PPChartControl.PrintPreview");
			printText = service.Translate("PPChartControl.Print");
			propertiesText = service.Translate("PPChartControl.Properties");
			setScaleToDefaultText = service.Translate("PPChartControl.SetScaleToDefault");
			bufferSizeAxisTextFormatText = service.Translate("PPChartControl.BufferSizeAxisTextFormat");
			queueSizeAxisTextFormatText = service.Translate("PPChartControl.QueueSizeAxisTextFormat");
			fftInformationText = service.Translate("PPChartControl.FftInformation");
			wouldYouLikeToFilterTheSignalsText = service.Translate("PPChartControl.WouldYouLikeToFilterTheSignalsText");
			wouldYouLikeTheSignalsInDecibelsText = service.Translate("PPChartControl.WouldYouLikeTheSignalsInDecibelsText");
			frequencyText = service.Translate("PPChartControl.Frequency");
			invalidFileFormatTextFormat = service.Translate("PPChartControl.InvalidFileFormatTextFormat");
			allFilesText = service.Translate("Common.AllFiles");
			plotErrorText = service.Translate("PPChartControl.PlotError");
			fftErrorText = service.Translate("PPChartControl.FftErrorText");
			commandPositionText = service.Translate("PPChartControl.CommandPosition");
			actualPositionText = service.Translate("PPChartControl.ActualPosition");
			commandAndActualPositionText = service.Translate("PPChartControl.CommandAndActualPosition");
			commandVelocityText = service.Translate("PPChartControl.CommandVelocity");
			actualVelocityText = service.Translate("PPChartControl.ActualVelocity");
			commandAndActualVelocityText = service.Translate("PPChartControl.CommandAndActualVelocity");
			commandAccelerationText = service.Translate("PPChartControl.CommandAcceleration");
			actualAccelerationText = service.Translate("PPChartControl.ActualAcceleration");
			commandAndActualAccelerationText = service.Translate("PPChartControl.CommandAndActualAcceleration");
			servoCommandText = service.Translate("PPChartControl.ServoCommand");
			followingErrorText = service.Translate("PPChartControl.FollowingError");
			commandPositionGantryFollowerText = service.Translate("PPChartControl.CommandPositionGantryFollower");
			gantryPositionText = service.Translate("PPChartControl.GantryPosition");
			actualVelocityGantryFollowerText = service.Translate("PPChartControl.ActualVelocityGantryFollower");
			actualAccelerationGantryFollowerText = service.Translate("PPChartControl.ActualAccelerationGantryFollower");
			servoCommandGantryFollowerText = service.Translate("PPChartControl.ServoCommandGantryFollower");
			followingErrorGantryFollowerText = service.Translate("PPChartControl.FollowingErrorGantryFollower");
			gantryFollowingErrorText = service.Translate("PPChartControl.GantryFollowingError");
			actualPositionGantryFollowerText = service.Translate("PPChartControl.ActualPositionGantryFollower");
			normalizedWrtToInitialValuesText = service.Translate("PPChartControl.NormalizedWrtToInitialValues");
			normalizedWrtToHomePositionText = service.Translate("PPChartControl.NormalizedWrtToHomePosition");
			actualCurrentText = service.Translate("PPChartControl.ActualCurrent");
			actualCurrentResponseText = service.Translate("PPChartControl.ActualCurrentResponse");
			sampleTimeIsZeroText = service.Translate("PPChartControl.SampleTimeIsZero");
			firstDerivativeErrorText = service.Translate("PPChartControl.FirstDerivativeError");
			secondDerivativeErrorText = service.Translate("PPChartControl.SecondDerivativeError");
			thirdDerivativeErrorText = service.Translate("PPChartControl.ThirdDerivativeError");
			textFilesText = service.Translate("PPChartControl.TextFiles");
			pppFilesText = service.Translate("PPChartControl.PppFiles");
			SuspendLayout();
			toolStripMenuItem_File.Text = service.Translate("PPChartControl.File");
			openPlotDataToolStripMenuItem.Text = service.Translate("PPChartControl.OpenPlot");
			savePlotDataToolStripMenuItem.Text = service.Translate("PPChartControl.SavePlot");
			saveRawDataToolStripMenuItem.Text = service.Translate("PPChartControl.SaveRawData");
			pageSetupToolStripMenuItem.Text = service.Translate("PPChartControl.PageSetup");
			printPreviewToolStripMenuItem.Text = service.Translate("PPChartControl.PrintPreview");
			printToolStripMenuItem.Text = service.Translate("PPChartControl.Print");
			toolStripMenuItem_View.Text = service.Translate("PPChartControl.View");
			toolStripMenuItem_FFT.Text = service.Translate("PPChartControl.FFT");
			smoothToolStripMenuItem.Text = service.Translate("PPChartControl.Smooth");
			toolStripMenuItem_Tools.Text = service.Translate("PPChartControl.Tools");
			modifyPlotItemsToolStripMenuItem.Text = service.Translate("PPChartControl.ModifyPlotItems");
			ResumeLayout(false);
		}

		protected override void Dispose(bool disposing)
		{
			if (disposing && components != null)
			{
				components.Dispose();
			}
			base.Dispose(disposing);
		}

		private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			this.menuStrip1 = new System.Windows.Forms.MenuStrip();
			this.toolStripMenuItem_File = new System.Windows.Forms.ToolStripMenuItem();
			this.openPlotDataToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
			this.savePlotDataToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
			this.saveRawDataToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
			this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
			this.pageSetupToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
			this.printPreviewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
			this.printToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
			this.toolStripMenuItem_View = new System.Windows.Forms.ToolStripMenuItem();
			this.toolStripMenuItem_FFT = new System.Windows.Forms.ToolStripMenuItem();
			this.smoothToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
			this.toolStripMenuItem_Tools = new System.Windows.Forms.ToolStripMenuItem();
			this.modifyPlotItemsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
			this.zg1 = new ZedGraph.ZedGraphControl();
			this.panel1 = new System.Windows.Forms.Panel();
			this.zedGraphtoolTip = new System.Windows.Forms.ToolTip(this.components);
			this.menuStrip1.SuspendLayout();
			this.panel1.SuspendLayout();
			base.SuspendLayout();
			this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[3] { this.toolStripMenuItem_File, this.toolStripMenuItem_View, this.toolStripMenuItem_Tools });
			this.menuStrip1.Location = new System.Drawing.Point(0, 0);
			this.menuStrip1.Name = "menuStrip1";
			this.menuStrip1.Padding = new System.Windows.Forms.Padding(8, 2, 0, 2);
			this.menuStrip1.Size = new System.Drawing.Size(432, 28);
			this.menuStrip1.TabIndex = 2;
			this.menuStrip1.Text = "menuStrip1";
			this.toolStripMenuItem_File.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[7] { this.openPlotDataToolStripMenuItem, this.savePlotDataToolStripMenuItem, this.saveRawDataToolStripMenuItem, this.toolStripSeparator1, this.pageSetupToolStripMenuItem, this.printPreviewToolStripMenuItem, this.printToolStripMenuItem });
			this.toolStripMenuItem_File.Name = "toolStripMenuItem_File";
			this.toolStripMenuItem_File.Size = new System.Drawing.Size(44, 24);
			this.toolStripMenuItem_File.Text = "File";
			this.openPlotDataToolStripMenuItem.Name = "openPlotDataToolStripMenuItem";
			this.openPlotDataToolStripMenuItem.Size = new System.Drawing.Size(188, 24);
			this.openPlotDataToolStripMenuItem.Text = "Open Plot (.ppp)";
			this.openPlotDataToolStripMenuItem.Click += new System.EventHandler(openPlotDataToolStripMenuItem_Click);
			this.savePlotDataToolStripMenuItem.Name = "savePlotDataToolStripMenuItem";
			this.savePlotDataToolStripMenuItem.Size = new System.Drawing.Size(188, 24);
			this.savePlotDataToolStripMenuItem.Text = "Save Plot (.ppp)";
			this.savePlotDataToolStripMenuItem.Click += new System.EventHandler(savePlotDataToolStripMenuItem_Click);
			this.saveRawDataToolStripMenuItem.Name = "saveRawDataToolStripMenuItem";
			this.saveRawDataToolStripMenuItem.Size = new System.Drawing.Size(188, 24);
			this.saveRawDataToolStripMenuItem.Text = "Save Raw Data";
			this.saveRawDataToolStripMenuItem.Click += new System.EventHandler(saveRawDataToolStripMenuItem_Click);
			this.toolStripSeparator1.Name = "toolStripSeparator1";
			this.toolStripSeparator1.Size = new System.Drawing.Size(185, 6);
			this.pageSetupToolStripMenuItem.Name = "pageSetupToolStripMenuItem";
			this.pageSetupToolStripMenuItem.Size = new System.Drawing.Size(188, 24);
			this.pageSetupToolStripMenuItem.Text = "Page Setup";
			this.pageSetupToolStripMenuItem.Click += new System.EventHandler(pageSetupToolStripMenuItem_Click);
			this.printPreviewToolStripMenuItem.Name = "printPreviewToolStripMenuItem";
			this.printPreviewToolStripMenuItem.Size = new System.Drawing.Size(188, 24);
			this.printPreviewToolStripMenuItem.Text = "Print Preview";
			this.printPreviewToolStripMenuItem.Click += new System.EventHandler(printPreviewToolStripMenuItem_Click);
			this.printToolStripMenuItem.Name = "printToolStripMenuItem";
			this.printToolStripMenuItem.Size = new System.Drawing.Size(188, 24);
			this.printToolStripMenuItem.Text = "Print";
			this.printToolStripMenuItem.Click += new System.EventHandler(printToolStripMenuItem_Click);
			this.toolStripMenuItem_View.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[2] { this.toolStripMenuItem_FFT, this.smoothToolStripMenuItem });
			this.toolStripMenuItem_View.Name = "toolStripMenuItem_View";
			this.toolStripMenuItem_View.Size = new System.Drawing.Size(53, 24);
			this.toolStripMenuItem_View.Text = "View";
			this.toolStripMenuItem_FFT.CheckOnClick = true;
			this.toolStripMenuItem_FFT.Name = "toolStripMenuItem_FFT";
			this.toolStripMenuItem_FFT.Size = new System.Drawing.Size(130, 24);
			this.toolStripMenuItem_FFT.Text = "FFT";
			this.toolStripMenuItem_FFT.Click += new System.EventHandler(toolStripMenuItem_FFT_Click);
			this.smoothToolStripMenuItem.Name = "smoothToolStripMenuItem";
			this.smoothToolStripMenuItem.Size = new System.Drawing.Size(130, 24);
			this.smoothToolStripMenuItem.Text = "Smooth";
			this.smoothToolStripMenuItem.Click += new System.EventHandler(smoothToolStripMenuItem_Click);
			this.toolStripMenuItem_Tools.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[1] { this.modifyPlotItemsToolStripMenuItem });
			this.toolStripMenuItem_Tools.Name = "toolStripMenuItem_Tools";
			this.toolStripMenuItem_Tools.Size = new System.Drawing.Size(57, 24);
			this.toolStripMenuItem_Tools.Text = "Tools";
			this.modifyPlotItemsToolStripMenuItem.Name = "modifyPlotItemsToolStripMenuItem";
			this.modifyPlotItemsToolStripMenuItem.Size = new System.Drawing.Size(195, 24);
			this.modifyPlotItemsToolStripMenuItem.Text = "Modify Plot Items";
			this.modifyPlotItemsToolStripMenuItem.Click += new System.EventHandler(modifyPlotItemsToolStripMenuItem_Click);
			this.zg1.Dock = System.Windows.Forms.DockStyle.Fill;
			this.zg1.Location = new System.Drawing.Point(0, 0);
			this.zg1.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5);
			this.zg1.Name = "zg1";
			this.zg1.ScrollGrace = 0.0;
			this.zg1.ScrollMaxX = 0.0;
			this.zg1.ScrollMaxY = 0.0;
			this.zg1.ScrollMaxY2 = 0.0;
			this.zg1.ScrollMinX = 0.0;
			this.zg1.ScrollMinY = 0.0;
			this.zg1.ScrollMinY2 = 0.0;
			this.zg1.Size = new System.Drawing.Size(432, 352);
			this.zg1.TabIndex = 3;
			this.panel1.AutoScroll = true;
			this.panel1.Controls.Add(this.zg1);
			this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
			this.panel1.Location = new System.Drawing.Point(0, 28);
			this.panel1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
			this.panel1.Name = "panel1";
			this.panel1.Size = new System.Drawing.Size(432, 352);
			this.panel1.TabIndex = 4;
			base.AutoScaleDimensions = new System.Drawing.SizeF(8f, 16f);
			base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
			base.Controls.Add(this.panel1);
			base.Controls.Add(this.menuStrip1);
			base.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
			base.Name = "PPChartControl";
			base.Size = new System.Drawing.Size(432, 380);
			base.Load += new System.EventHandler(PPChartControl_Load);
			base.Resize += new System.EventHandler(PPChartControl_Resize);
			this.menuStrip1.ResumeLayout(false);
			this.menuStrip1.PerformLayout();
			this.panel1.ResumeLayout(false);
			base.ResumeLayout(false);
			base.PerformLayout();
		}
	}
}
